Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97770

How to get web driver of current web element?

$
0
0

The condition is to get web driver(WebDriver) and locator(By) of current web element.

I have list of web elements in that i am iterating the element one by one.

Whichever the element i will get i want webdriver and By locator of that element so that i can test provided driver and locator has proper value or not.

Does anybody know how to get this thing done!!

Below i have gave my code sample:

List<WebElement> myList = driver.findElement(By.xpath("//div[@role ='menubar']/*"));
ListIterator<WebElement> simpleChildIterator =  myList.listIterator();

while(simpleChildIterator.hasNext())
{
    WebDriver d = simpleChildIterator.next().getWebDriver();//here i want to get driver from retrieved element
    By l = simpleChildIterator.next().getBy();// as well as i want locator for same element
}

Viewing all articles
Browse latest Browse all 97770

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>