Find the element using combination of resourceid and xpath

Is it possible to find element using below:

WebElement channels = driver.findElement(By.id(“com.mobitv.client.connect.mobile:id/channel_list”));

WebElement channel = channels.findElement(By.xpath("//android.widget.LinearLayout[1]"));

Thanks

1 Like

Laxmi,
You can use
WebElement channel = driver.findElement(new ByChained(By.id(“com.mobitv.client.connect.mobile:id/channel_list”), By.xpath("//android.widget.LinearLayout[1]")));
So, it tries to find one element by the id, and from that node, it tries to find the element using the xpath. You can also use others locators like className, or name.
I hope this could help you.

3 Likes