Monday, 13 October 2014

Selenium - java syntax for locating elements in selenium Webdriver

Selenium - java syntax for finding elements in selenium Webdriver

1.Method : By ID
Syntax: driver.findElement(By.id(<element ID>))
Description: Finds an element the using ID attribute

2.Method : By name
Syntax: driver.findElement(By.name(<element name>))
Description: Finds an element the using Name attribute

3.Method : By By tag name
Syntax: driver.findElement(By. By tag name (<element ID>))
Description: Finds an element the using tag name attribute

4.Method : By link text
Syntax: driver.findElement(By. link text (<element link text >))
Description: Finds an element the using link text  attribute

5.Method : By partial link text
Syntax: driver.findElement(By. partial link text (<element ID>))
Description: Finds an element the using partial link text attribute

6.Method : By CSS
Syntax: driver.findElement(By. cssSelector (<element ID>))
Description: Finds an element the using cssSelector attribute

7.Method : By xpath
Syntax: driver.findElement(By. xpath (<element ID>))
Description: Finds an element the using xpath attribute



No comments:

Post a Comment