Unable to identify an UI Elemnt | Selenium Forum
M
Posted on 20/07/2016
Hi,

When I inspect a Menu item on the website called Pre-Owned, I get below attributes but I don't know which one to grab to identify that UI element -

<a class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" href="/Preowned/PreownedHomePage/">
<span>Pre-Owned</span>
</a>

Another example of another element is -

<a class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" href="#">
<span>Reports</span>
</a>

Please advice.

Thank You!

M
Replied on 21/07/2016

try write xpaths with couple of them together.

like this

//*[@class='some_thing' and id='some_thing']


M
Replied on 21/07/2016

Thank you for responding back.
See that's my problem that it doesn't have any meaningful attributes that I can pick. All it shows is Class (dropdown-toggle) and href(#), and these values are common for few of the elements. So, they are not really the unique identifiers. What should I do in this case? Can Span value be helpful? - <span>Pre-Owned</span>

Thanks You!


M
Replied on 22/07/2016

you can do

//span[@text='some text']

or

you pick some higher element and bring it down to a or span like this.
//*[@class='some_higher_thing' and id='some_higher_thing']/a/span