Reputation: 39030
I have a page with the following snippet in the HTML:
...
<tbody id="c_scopePane4_tbody">
<tr id="c_scopePane4_tr_header">
...
</tr>
</tbody>
...
Now I'm trying to specify the <tr>
tag with an XPath expression from within Selenium. Here's what I try:
//tr[@id='c_scopePane4_tr_header']
This tells me
[error] locator not found: //tr[@id='c_scopePane4_tr_header'], error = Error:
Element //tr[@id='c_scopePane4_tr_header'] not found
But if I change the XPath expression to:
//*[@id='c_scopePane4_tr_header']
...then it works. What gives?
Upvotes: 0
Views: 1104
Reputation: 5168
Alternate CSS Style locator:
css=tr#c_scopePane4_tr_header
or DOM Style:
dom=document.getElementById("c_scopePane4_tr_header")
Upvotes: 0
Reputation: 8223
It's working for me with the same snippet. Perhaps there's something else in your HTML that's causing problems? Do you have more than one <tr>
(or any other element) with the same ID?
Because IDs are (meant to be) unique, you should be able to use your second XPath expression with confidence. Alternatively you can use the following, but be sure to precede your locator with xpath=
so that Selenium knows the type of locator you are using:
xpath=id('c_scopePane4_tr_header')
Also, if you just want to select the <tr>
element then you can also use one of the following:
Upvotes: 3