Tuesday, June 4, 2013

Element Locator in Selenium

Element Locators tell Selenium which HTML element a command refers to.

The format of a locator is:  locatorType=argument
Example: - (“link=click”)

id=id
Select the element with the specified @id attribute

name=name
Select the first element with the specified @name attribute.
  username
  name=username

xpath=xpathExpression
Locate an element using an XPath expression.
  xpath=//img[@alt='The image alt text']
  xpath=//table[@id='table1']//tr[4]/td[2]
link=textPattern
Select the link (anchor) element which contains text matching the specified
pattern.
  link=The link text

No comments:

Post a Comment