Tuesday, January 10, 2012

Object Identification In Selenium

Identifiers

Syntax1

Syntax2

Comments

id

id =id

id

Select the element with the specified @id attribute

name

name=username

username

Select the first element with the specified @name attribute

dom

dom=document.images[1]

Find an element using JavaScript traversal of the HTML DOM

xpath

xpath=//img[@alt='do]

//img[0]

Locate an element using an XPath expression

link

link=The link text

Select the link (anchor) element which contains text matching.

CSS

css=a[href="#id3"]

css =a[href="#id3"]

Select the element using css selectors