Chapter 4 – Object String | Webdriver

Object String

Object String is a string that is used to identify an automation object based on its attributes and hierarchy. In a Webdriver, we have following locators to identify an object:

  1. XPath
  2. Id
  3. Name
  4. TagName
  5. ClassName
  6. CssSelector
  7. LinkText
  8. PartialLinkText

The object string for webdriver has the following format:

<Locator>::valueThe object string for the search button on google will be “name::btnG” e.g.  wd.Click “name::btnG”

Nested Objects

Nested objects are the child objects which lie under some parent object. The object string for the nested object has the following format:<Locator(Parent)>::value>==><Locator(Child)>::value

e.g.  “name::Parent>==>id::child”

Index

When the object string points to more than one object then we can use the concept of index.

e.g. wd.Click “name::btnG,index::1”

Note: index starts from 0

 

Tags:

Add a Comment

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