gpt4 book ai didi

c# - 在C#中使用XPath选择单选按钮

转载 作者:行者123 更新时间:2023-12-03 17:34:08 25 4
gpt4 key购买 nike

我正在尝试使用XPath命令选择特定的单选按钮:

driver.FindElement(By.XPath("//td[contains(@input id,   'SearchTypePatientNameDob')]")).Click();


包含我想要的按钮的列表如下:

<tr>
<td>
<input id="RadioButtonSearchTypePatientNameDob" type="radio" value="SearchTypePatientNameDob" name="SearchType">
<span class="Instructions">Patient Name / Patient Date of Birth</span>
</td>
</tr>


我的命令找不到要选择/单击的按钮。任何建议将大有裨益。

最佳答案

您需要找到input元素,而不是td元素:

//input[contains(@id, 'SearchTypePatientNameDob')]


请注意,我看不到任何合理的原因,为什么您不使用简单的 By.Id定位器:

driver.FindElement(By.Id("RadioButtonSearchTypePatientNameDob")).Click();


您可能还需要显式 wait for the element to be present

关于c# - 在C#中使用XPath选择单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30463170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com