【发布时间】:2015-10-21 22:08:17
【问题描述】:
我是自动化世界的新手,正在致力于自动化 BBC 网站。我有许多链接以及该链接中存在的文本。 .我想单击带有文本“辅助功能帮助”的特定链接。请告诉我该怎么做。以下是我的代码:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class BBC_AllLinks {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("http://www.bbc.com");
List<WebElement> allLinks = driver.findElements(By.tagName("a"));
//Total number of links in the webpage
System.out.println("Total Links--> "+allLinks.size());
//35th index
Thread.sleep(4000);
for (int i =0; i<=allLinks.size();i++)
System.out.println(allLinks.get(i).getText()+"----"+allLinks.get(i).isDisplayed());
}
}
【问题讨论】:
-
请更清楚地添加您想要做什么?