Selenium ByChained Class - Codoid
Select Page
Codoid Blog

Selenium ByChained Class

Irrespective of the business that your client is in, marketing is an integral part of their operations. In fact, in this day and age of social.

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:

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

Hope it helps!

Written By

Submit a Comment

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


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:

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

Hope it helps!