gpt4 book ai didi

java - 尝试使用 Selenium Web 驱动程序获取 Mercury Tours 主页中的所有链接时出现异常

转载 作者:行者123 更新时间:2023-12-01 12:31:06 24 4
gpt4 key购买 nike

System.setProperty("Webdriver.chrome.driver", "F:/shiva testing/chromedriver.exe");
//System.out.println("hai");

WebDriver driver=new ChromeDriver();
driver.get("http://newtours.demoaut.com/");
String underConsTitle= "Under Construction : Mercury Tours";
//driver.get("http://www.google.co.in/");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
java.util.List<WebElement>linkElements =driver.findElements(By.tagName("a"));
String[]linkText=new String[linkElements.size()];
int i=0;
for(WebElement e:linkElements)
{
linkText[i]= e.getText();
i++;

}
for(String t: linkText)
{
((WebElement) driver.findElements(By.linkText(t))).click();
if(driver.getTitle().equals(underConsTitle))

//if (driver.getTitle().equals(underConsTitle))
{
System.out.println("\"" +t+"\"" +"is under construction");

}
else
{
System.out.println("\"" +t+"\"" +"working");
}
driver.navigate().back();
The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html    at com.google.common.base.Preconditions.checkState(Preconditions.java:177)    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:117)    at mypackage.Getalllinks.main(Getalllinks.java:22)

最佳答案

你的问题在第1行,应该是:

System.setProperty("webdriver.chrome.driver", "F:/shiva testing/chromedriver.exe");

注意“webdriver”的大小写!

关于java - 尝试使用 Selenium Web 驱动程序获取 Mercury Tours 主页中的所有链接时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25913989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com