Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium webdriver- Identify an element
    text
    copied!<p>I am new to automation (selenium).Scenario :To identify the element of the mobile title on any mobile site(eg:flipkart).I wanted to know whether there is any other way apart from the href/title to identify the element using selenium webdriver?I want to make it generic as the mobile phone might not be available after sometime.</p> <p><a href="http://www.flipkart.com/mobiles/sony~brand/pr?sid=tyy,4io&amp;_pop=flyout&amp;otracker=hp_submenu_new_mobile_Mobiles_Sony#jumpTo=228|20" rel="nofollow">http://www.flipkart.com/mobiles/sony~brand/pr?sid=tyy,4io&amp;_pop=flyout&amp;otracker=hp_submenu_new_mobile_Mobiles_Sony#jumpTo=228|20</a></p> <p>Use this url for the scenario.</p> <p>I am using Java as the language.Selenium version : 1.10.0 As per my knowledge we can use id,name,css and xpath to identify the element,but what do i do when i have to <strong>always</strong> select the second phone title no matter which phone it is.How do I create the xpath for this?or is there any other way to do so?Please let me know.</p> <p>These are the html tags for the first and second phones for the above url:</p> <pre class="lang-html prettyprint-override"><code>&lt;a class="fk-display-block" title="Sony Xperia SP (Black)" href="/sony-xperia-sp/p/itmdjmz3z9hgbhdm?pid=MOBDJMZ2U6JFHZZH&amp;ref=ab7f3941-7bfb-4119-a446-555c42f4248a"&gt; Sony Xperia SP (Black) &lt;/a&gt; &lt;a class="fk-display-block" title="Sony Xperia Miro (Black)" href="/sony-xperia-miro/p/itmdda7crgzwqzhp?pid=MOBDDA5Y6BKX6VHR&amp;ref=f8fea7a0-d9c0-4264-8fc9-959f09407436"&gt; Sony Xperia Miro (Black) &lt;/a&gt; </code></pre> <p>As we can observe that the only difference between two phones are the title , the href and the link text.The class is the same for all of the phones.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload