Select Page
Codoid Blog

Selenium ByChained Class

Being a leading QA Company, we write blogs on all prominent software testing topics and tools using our real-world experience. So stay sharp by subscribing to our Newsletter.

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.

<div id="div1">
<div id="div2">
<input type="text" id="txt1"/>

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:

driver.findElement(new ByChained("div2"),"div1"),"txt1"))).sendKeys("Codoid");  

Hope it helps!


Submit a Comment

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

Talk to our Experts

Amazing clients who
trust us