【发布时间】:2016-03-03 18:04:56
【问题描述】:
我有一个 HTML 页面,其中有一些复选框,旁边有一个名称。使用 XPATH,我可以使用 = 来找到标题属性中包含完整文本的复选框以匹配完整文本。 例如
//div[@id="operations_add_process_list_tab_groups_tab_standard_1"]//span//input[@title="CRM : crm"]
我不想匹配整个文本,我想通过使用一些文本来找到它,例如我想在标题属性中找到“CRM”的复选框。 我不想使用“CRM:crm”
我可以使用 contains 关键字来查找“CRM”在标题属性中的位置吗? 我不知道这个的语法。
我试过了://div[@id="operations_add_process_list_tab_groups_tab_standard_1"]//span//input[@title[contains(text(), CRM : crm")]]
HTML 是:
<div id="operations_add_process_list_tab_groups_tab_standard_1">
<span>
<span>
<span/>
<span>
<span/>
<span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;">
<input type="checkbox" checked="" title="CRM : crm" tabindex="-1"/>
CRM : crm
</span>
</span>
<span>
<span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;">
<input type="checkbox" checked="" title="ESCR : escr" tabindex="-1"/>
ESCR : escr
</span>
</span>
<span>
<span style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;display:block;">
<input type="checkbox" checked="" title="ORCHARD : orchard" tabindex="-1"/>
ORCHARD : orchard
</span>
</span>
谢谢, 里亚兹
【问题讨论】:
-
试试
//div[@id="operations_add_process_list_tab_groups_tab_standard_1"]//span//input[contains(@title, "CRM : crm")]
标签: python-2.7 selenium selenium-webdriver