general selenium questions

By | April 23, 2019

1. Find element using xpath and cssSelector.

Html code: <a class=”shopicon relative”>Shopping</a>

Solution: 

//a[@class=’shopicon relative’]   –> using xpath in firefox

.shopicon.relative   –> using cssSelector in chrome

//a[text()=’Shopping’] –> text() method

2. In the “in.rediff.com” website, ways to find NEWS link are:

Using cssSelector:

.navbar>:nth-child(1)>:nth-child(2)

.navbarul>:nth-child(2)

Using xpath:

//a[text()=’NEWS’]

 

Related articles:

Waits in Selenium WebDriver

Leave a Reply

Your email address will not be published. Required fields are marked *