There are times that you will need to find elements that are the same except for the difference in one or two attributes. To handle this, we can add the attributes to the query so that we can try to make the element more unique for use in the test. The format can be used for any attribute on any element.
It will always follow the xpath=//element [@attribute=’attribute value’].
For example, if you have two div elements on the page but they only differ by the class attribute, your XPath query would look like
1) Two object has same attributes
Related Page: Finding Elements By XPATH And Using CSS - SELENIUM
Face book code:-
ocat=707″ class=”current”>Travel Gear
Using Prent element:-
Example for Link:-
//a[@class=’current’] –its not working
Xpath using position:-
//element[@att=’attname’]/element1/element2 //dd[@class=’last odd’]/ol/li/a
//input[@type=’submit’ and @value=’Log In’]
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
|Selenium Training||Dec 09 to Dec 24||View Details|
|Selenium Training||Dec 12 to Dec 27||View Details|
|Selenium Training||Dec 16 to Dec 31||View Details|
|Selenium Training||Dec 19 to Jan 03||View Details|
Madhuri is a Senior Content Creator at MindMajix. She has written about a range of different topics on various technologies, which include, Splunk, Tensorflow, Selenium, and CEH. She spends most of her time researching on technology, and startups. Connect with her via LinkedIn and Twitter .
Copyright © 2013 - 2023 MindMajix Technologies