In this article, you are going to see an example of Selenium Webdriver ByChained class. Before jumping into the code, let’s understand what is ByChained class? ByChained class allows you to locate an element using its hierarchy in the DOM.
<html> <body> <div id="div1"> <div id="div2"> <input type="text" id="txt1"/> </div> </div> </body> </html>
If you want to locate the textbox (txt1) from the above HTML using ByChained class, you need to pass ByChained object with By arguments in sequence. Note: You can also locate the element using XPath with DOM hierarchy.
ByChained Class Example:
Hope it helps!