I am willing to get the innerText and click on it. The text is Customer Service Inquiry.
I have tried:
.FindElementsByXPath("//*[text()[contains(.listItem, 'Customer Service Inquiry')]]").Click
This does not work as it gives error that it is not a valid xpath expression
Further, this works but I am wanting to click by what the inner text says.
.FindElementByXPath("//*[@id='listFav_ALLOUTSECURITY0000000000000000008276_APP_P4210_W4210E_PSG0021_20']").click
The html
<div id="listContentHolder"> == $0 > <div id="listOCL" slot="0" style="height: 57px; top: @px;">.</div> > <div id="listRecipts" slot="1" style="height: 57px; top: 57px;">.</div> <div id="listFav" slot="2" style="height: 153px; top: 114px;"> > <div id="listFavHeader" oncontextmenu="javascript:CARO.updateDropdownMenuView(this,event);jdebebGUIdoToggleSubMenu(this,'caroTabContextMenu', event, true)
;" toplistitem="false">.</div> <div id="listFavouter" style="height: 128px;"> <div id="listFavInner" style="height: 128px; top: Opx;">
<div id="listFav_manageFavs" aria-labelledby="appCaption_fav_manageFavs" role="link" tabindex="0" style="user-select: none; top: Opx;">.</div> > <div id="listFav_ALLOUTSECURITY0000000000000000008582_APP_P4210_W4210E_PSG0099_10" aria-labelledby="appCaption_fav_ALLOUTSECURITY0000000000000000008582_APP_P4210_W 4210E_PSG0099_10" role="link" tabindex="0" style="user-select: none; top: 32px;">.</div>
<div id="listFav_ALLOUTSECURITY0000000000000000008276_APP_P4210_W4210E_PSG0021_20" aria-labelledby="appCaption_fav_ALLOUTSECURITY0000000000000000008276_APP_P4210_W 4210E_PSG0021_20" role="link" tabindex="0" style="user-select: none; top: 64px;"> <table >
<tbody>
<tr> >
<td >.</td>
<td >Customer Service Inquiry</td>
</tr>
</tbody>
</table>
</div>
<div id="listFav_21343ad6_1803cf57c8c__7ffeE1PDJAS3__APP_P41026_W41026E_PSA0001_30" aria-labelledby="appCaption_fav_21343ad6_1803cf57c8c__7ffeE1PDJAS3_APP_P41026_ W41026E_PSA0001_30" role="link" tabindex="0" style="user-select: none; top: 96px;">.</div> </div> <a necessary="false" style></a>
<a necessary="false" stylex/a> </div> </div> </div>
CodePudding user response:
To click on the element with text as Customer Service Inquiry you can use either of the following locator strategies:
Using FindElementByXPath and only the innerText:
.FindElementByXPath("//td[text()='Customer Service Inquiry']").click
Using FindElementByXPath along with the class and the innerText:
.FindElementByXPath("//td[@class='listText' and text()='Customer Service Inquiry']").click