Cucumber Table -

Difference between single ‘/’ or double ‘//’

Single slash ‘/’ anywhere in xpath signifies to look for the element immediately inside the parent element.
Double slash ‘//’ signifies to look for any child or nested-
child element inside the parent element.



Relative xpath using single ‘/’ for Login link


Relative xpath using double ‘//’ for Login link.


Don’t use “*”, always use the tag name.

Using Text of the element to build xpath
Finding Login link: //div[@class='homepage-hero']//a[text()='Enroll now']

Using Contains to find the elements: Syntax: //tag[contains(attribute, ‘value’)]

Finding Login link:

//div[@id='navbar']//a[contains(text(),'Login')] //div[@id='navbar']//a[contains(@class,'navbar-link') and contains(@href,'sign_in')]

Using Starts-With to find the elements: Syntax: //tag[starts-with(attribute, ‘value’)]

Finding Login link:


Syntax: xpath-to-some-element//parent::<tag>

Preceding Sibling
Syntax: xpath-to-some-element//preceding-sibling::<tag>

Following Sibling
Syntax: xpath-to-some-element//following-sibling::<tag>

Tab through the page

WebElement webElement = driver.findElement(By.xpath(""));//You can use xpath, ID or name whatever you like



Selenium keyboard events