1

HTML Snapshot:

enter image description here

Element Snapshot:

enter image description here

I want to write xpath for 'Yes' label (Green color mentioned in UI image). I'm new for automation & Please help me to resolve. I have add my HTML code & UI

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Please [don't post screenshots of code or data](http://idownvotedbecau.se/imageofcode) - post a text here so people are able to use it to very their answer code. – Filburt Dec 01 '21 at 12:06

1 Answers1

0

The is basically an <input> element associated with the <label> with text as Yes and to click() on it you can use either of the following Locator Strategies:

  • XPath:

    driver.FindElement(By.XPath("//label[contains(., 'Yes')]//ancestor::input[1]")).Click();
    

Ideally, you have to induce WebDriverWait for the desired ElementToBeClickable() and you can use either of the following Locator Strategy:

  • XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//label[contains(., 'Yes')]//ancestor::input[1]"))).Click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352