March 7, 2018
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:
- XPath
- Id
- Name
- TagName
- ClassName
- CssSelector
- LinkText
- 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