I am planning a tool in Java which would have a drop down containing all the elements of a web page. Is there any way I can read those into a data structure?
Yes, there is a way.
Here is some pseudo-code:
List<WebElement> el = driver.findElements(By.cssSelector("*"));
for ( WebElement e : el ) {
add(e.tagName());
}
non-pseudo C# version of above: (although I'm just displaying the results in a console
IReadOnlyCollection<IWebElement> el = driver.FindElements(By.CssSelector("*"));
foreach (IWebElement elm in el)
{
Console.WriteLine(elm.TagName + elm.Text);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With