HTML Snapshot:
Element Snapshot:
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
CodePudding user response:
The radio-button 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();