Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium中id、类型和名称相同的复选框的XPATH_Selenium_Xpath_Checkbox - Fatal编程技术网

Selenium中id、类型和名称相同的复选框的XPATH

Selenium中id、类型和名称相同的复选框的XPATH,selenium,xpath,checkbox,Selenium,Xpath,Checkbox,请查看以下代码: id=idConfirmedCheckbox的XPath是什么 <td class="tdCenter"> <input id="idConfirmedCheckbox" type="checkbox" onclick="return idConfirmedClicked(this);" name="idConfirmedCheckbox"/> <input id="Customer_Person_Identifications_Identific

请查看以下代码:

id=idConfirmedCheckbox
的XPath是什么

<td class="tdCenter">
<input id="idConfirmedCheckbox" type="checkbox" onclick="return idConfirmedClicked(this);" name="idConfirmedCheckbox"/>
<input id="Customer_Person_Identifications_Identification_0_Confirmed" type="hidden" value="N" name="Customer_Person_Identifications_Identification_0_Confirmed"/>
<input id="Customer_Person_Identifications_Identification_0_NotConfirmedDisabled" type="hidden" value="" name="Customer_Person_Identifications_Identification_0_NotConfirmedDisabled"/>
</td>
<td class="tdCenter">
<input id="idConfirmedCheckbox" type="checkbox" onclick="return idConfirmedClicked(this);" name="idConfirmedCheckbox"/>
<input id="Customer_Person_Identifications_Identification_1_Confirmed" type="hidden" value="N" name="Customer_Person_Identifications_Identification_1_Confirmed"/>
<input id="Customer_Person_Identifications_Identification_1_NotConfirmedDisabled" type="hidden" value="" name="Customer_Person_Identifications_Identification_1_NotConfirmedDisabled"/>
</td>

试试下面的Xpath:

//input[@id='idConfirmedCheckbox']

根据需要将数组更改为1到2或3

//input[@id='idConfirmedCheckbox']


根据需要将阵列更改为1到2或3

已更新。我认为您需要一个具有相同id的单个元素。我相信您忘了提及它。更新了我的答案。如果遇到任何问题,请告诉我您希望使用xpath获得什么?您还可以为您提供的td element()提供上面层次结构中的代码/屏幕截图。如果有id和名称,为什么需要xpath?已更新。我认为您需要一个具有相同id的单个元素。我相信您忘了提及它。更新了我的答案。如果遇到任何问题,请告诉我您希望使用xpath获得什么?您还可以为您提供的td元素()提供层次结构中的代码/屏幕截图。如果有id和名称,您为什么需要xpath?线程“main”org.openqa.selenium.NoSuchElementException中的异常:没有这样的元素:无法定位元素:{“method”:“xpath”,“selector”:“//input[@id='idConfirmedCheckbox'和@type='checkbox'][2]”//input[@id='idConfirmedCheckbox'和@type='checkbox'][1]”已成功选中,但在选中第二个复选框时,上述错误即将出现。您做错了,我给出了不同的xpath,..我提到的xpath是(//input[@id='idConfirmedCheckbox'和@type='checkbox'])[1],而您正在尝试//input[@id='idConfirmedCheckb]‌​ox'和@type='checkbox'][2]线程“main”org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:{“method”:“xpath”,“selector”:“//input[@id='idConfirmedCheckbox'和@type='checkbox'][2]”}//input[@id='idConfirmedCheckbox'和@type='checkbox'][1]”已成功检查,但在检查第二个时,出现上述错误。您做错了,我给出了不同的xpath,其中。。我提到的xpath是(//input[@id='idConfirmedCheckbox'和@type='checkbox'])[1],您正在尝试//input[@id='idConfirmedCheckb]‌​“ox”和@type='checkbox'][2]您缺少右括号
(//input[@id='idConfirmedCheckbox' and @type='checkbox'])[1]