硒-查找网页的所有元素

问题描述:

我正在计划使用Java开发的工具,该工具将包含一个包含网页所有元素的下拉菜单.有什么办法可以将它们读入数据结构中?

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?

是的,有一种方法.

这是一些伪代码:

List<WebElement> el = driver.findElements(By.cssSelector("*"));

for ( WebElement e : el ) {
  add(e.tagName());
}