-3

I'm trying to get the NO value that is inside the specific fieldref

public GetValue()
{
    (ExpectedConditions.ElementToBeClickable(By.XPath("//input[contains(@fieldref =‘LineInput][@value='No'])")));
    updateLink.Click();
    return this;
}

but is not working

html

<input type="radio" autocomplete="off" fieldref="LineInput " objectref="l458D8E8BB59D4B818C2BA3417435B730" id="f_l458D8E8BB59D4B818C2BA3417435B730B7F_4_1_1" name="string_BF" class=" x-form-radio x-form-field" value="No">
JeffC
  • 22,180
  • 5
  • 32
  • 55
Mayi007
  • 1
  • 3
  • 1
    you're missing a single quote after the word LineInput. Also, you might want to delete that single quote and type it in again (copy paste different character) – Jawad Jan 09 '20 at 15:45
  • I try this and still doesn't work for me (ExpectedConditions.ElementToBeClickable(By.XPath("//input[contains(@fieldref ='LineInput')][@value='No']"))); I'm not sure what I'm missing I get this error invalided selector syntaxError SyntaxError: Failed to execute 'evaluate' on 'Document': The string '/ is not a valid XPath expression. (Session info: chrome=79.0.3945.117) – Mayi007 Jan 09 '20 at 16:15
  • .Text; after the xpath should do it – SublimizeD Jan 09 '20 at 17:18
  • Are you trying to return the value attribute of the INPUT element you posted? Your method is called `GetValue()` but it's not returning anything and all you do is execute a click in the method. What are you actually trying to do? – JeffC Jan 10 '20 at 05:29

2 Answers2

1

I think you have an error in your xpath expression in the way you use contains(); try changing it to:

//input[contains(@fieldref, 'LineInput')][@value='No']

or, alternatively:

//input[normalize-space(@fieldref)='LineInput'][@value='No']
Jack Fleeting
  • 24,385
  • 6
  • 23
  • 45
0

To click() on the element with value as No as the desired element is a dynamic element so you have to induce WebDriverWait for the desired ElementToBeClickable and you can use either of the following Locator Strategies as solutions:

  • CssSelector:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("input.x-form-radio.x-form-field[name='string_BF'][value='No']"))).Click();
    
  • XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@class=' x-form-radio x-form-field' and @name='string_BF'][@fieldref='LineInput ' and @value='No']"))).Click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352