我想要打印所有主要的模块链接...但是如果使用框架然后使用标签“a”将所有链接分开,我会打印所有链接。 请纠正我..
List All_Module_Links=driver.findElements(By.xpath("//*[@id='top-menu']"));
WebElement modules_box = All_Module_Links.get(0);
List links =modules_box.findElements(By.tagName("a"));
System.out.println("Total links are : "+links.size());
for(int i=0;i {
System.out.println(links.get(i).getText());
}![enter image description here][1]
答案 0 :(得分:1)
WebElement topmenu = driver.findElements(By.xpath("//*[@id='top-menu']"));
List<WebElement> links =topmenu.findElements(By.tagName("a"));
System.out.println("Total links are : "+links.size());
for(int i=0;i<links.size();i++)
{
System.out.println(links.get(i).getText());
}