【发布时间】:2018-09-08 10:00:31
【问题描述】:
请在下面找到两个选定输入字段的 HTML,但我需要选择第一个,请在我的 XPath 下方找到 - 请帮助我提前谢谢
//*[contains(@id,'CC_CARD_NUMBER_!SEPARATOR') and
contains(@parentquestion,"|_VISA")]
第一个输入
<input value="" class="form-control flleft fln masked" defaultvalue=""
id="CC_CARD_NUMBER_!SEPARATOR!_9beb0a0e-e089-4d9b-a7c3-75e69f40484c"
onclick="showChildQuestions(this);"
parentquestion="CC_CARD_TYPE_!SEPARATOR!_4185c1bd-b262-431e-a05d-c174f926a8bf_|_VISA"
questionid="CC_CARD_NUMBER_!SEPARATOR!_9beb0a0e-e089-4d9b-a7c3-75e69f40484c"
type="text" autocomplete="off" maxlength="16"
style="-webkit-text-security: disc;">
第二次输入
<input value="" class="form-control flleft fln masked" defaultvalue=""
id="CC_CARD_NUMBER_!SEPARATOR!_3c59ab5f-a770-454a-8ee6-d76fc32a9dea"
onclick="showChildQuestions(this);"
parentquestion="CC_CARD_TYPE_!SEPARATOR!_e245a7f5-d623-4a79-ad42-e2ec6c8c0dbf_|_VISA"
questionid="CC_CARD_NUMBER_!SEPARATOR!_3c59ab5f-a770-454a-8ee6-d76fc32a9dea"
type="text" autocomplete="off" maxlength="16"
style="-webkit-text-security: disc;">
【问题讨论】:
-
<input>标签相同,要构建唯一定位器,您需要使用父节点更新问题。
标签: java selenium selenium-webdriver xpath css-selectors