gpt4 book ai didi

java - 我想知道运行 java selenium 代码所需的版本

转载 作者:行者123 更新时间:2023-11-30 05:37:28 28 4
gpt4 key购买 nike

当我运行一个简单的 java selenium 代码来启动 Facebook 应用程序时,我收到错误“等待驱动程序服务器启动超时”。

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 浏览器已成功打开,但出现上述错误。

最佳答案

您可以通过此链接查看 selenium 和 webdrivers 的最新版本 https://www.seleniumhq.org/download/

此外,您还可以分享您的代码,以便更好地了解错误原因。

检查代码后,您将驱动程序的属性设置为错误的路径。属性 webdriver.chrome.driver 应该是 chrome 驱动程序而不是 chrome 可执行文件。

从该链接下载:https://www.seleniumhq.org/download/

关于java - 我想知道运行 java selenium 代码所需的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56311972/

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