Reputation: 4062
I have a HTML page with some checkboxes with a name beside it. Using XPATH I can locate the checkbox which has the complete text in the title attribute using = to match the complete text. E.g.
//div[@id="operations_add_process_list_tab_groups_tab_standard_1"]//span//input[@title="CRM : crm"]
I don't want to match the whole text, I would like to find it by using some of the text e.g. I would like to find the checkbox where "CRM" in the title attribute. I don't want to use "CRM : crm"
Can i use the contains keyword to find where "CRM" is in the title attribute? I do not know the syntax for this.
I tried: //div[@id="operations_add_process_list_tab_groups_tab_standard_1"]//span//input[@title[contains(text(), CRM : crm")]]
The HTML is:
<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>
Thanks, Riaz
Upvotes: 1
Views: 1339
Reputation: 934
The contains
is what you are looking for. In your case.
//input[contains(@title, "CRM")]
contains
can be used for any attribute and for text in the element as well.
Upvotes: 1