当我运行一个简单的Java硒代码来启动faceboook应用程序时,出现错误“等待驱动程序服务器启动超时”。
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:202)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:188)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at newpackage.PractAuto.main(PractAuto.java:10)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:40026/status] to be available after 20002 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197)
... 9 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 10 more
我的代码:
package newpackage;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class PractAuto {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/login/");
Thread.sleep(5000);
driver.findElement(By.name("email")).sendKeys("arunkumar3625@gmail.com");
driver.findElement(By.name("pass")).sendKeys("Password");
driver.findElement(By.id("loginbutton")).click();
driver.findElement(By.name("mercurymessages")).click();
driver.findElement(By.cssSelector("a[href*='https://www.facebook.com/messages/conversation-8148306']")).click();
}
Chrome浏览器已成功打开,但出现上述错误。
答案 0 :(得分:1)
您可以通过此链接检查硒的最新版本和网络驱动程序 https://www.seleniumhq.org/download/
此外,您可以共享代码以更好地理解错误原因。
检查代码后,您将驱动程序的属性设置为错误的路径。属性webdriver.chrome.driver应该是chrome驱动程序,而不是chrome可执行文件。
答案 1 :(得分:0)
从https://www.seleniumhq.org/download/下载最新的chrome驱动程序并将属性设置为:
System.setProperty("webdriver.chrome.driver","location of latest chrome driver")