如何使用 Selenium 和 C# 单击带有标签 Yes 的单选按钮
How to click on the radio button with label Yes using Selenium and C#
HTML快照:
元素快照:
我想为 'Yes' 标签编写 xpath(UI 图片中提到的绿色)。我是自动化新手,请帮我解决。我已经添加了我的 HTML 代码 & UI
radio-button is basically an <input>
element associated with the <label>
with text as Yes and to on it you can use either of the following :
XPath
:
driver.FindElement(By.XPath("//label[contains(., 'Yes')]//ancestor::input[1]")).Click();
理想情况下,你必须诱导 for the desired and you can use either of the following :
XPath
:
new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//label[contains(., 'Yes')]//ancestor::input[1]"))).Click();
HTML快照:
元素快照:
我想为 'Yes' 标签编写 xpath(UI 图片中提到的绿色)。我是自动化新手,请帮我解决。我已经添加了我的 HTML 代码 & UI
radio-button is basically an <input>
element associated with the <label>
with text as Yes and to
XPath
:driver.FindElement(By.XPath("//label[contains(., 'Yes')]//ancestor::input[1]")).Click();
理想情况下,你必须诱导
XPath
:new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//label[contains(., 'Yes')]//ancestor::input[1]"))).Click();