Selenium依赖:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
Edge驱动下载:
Microsoft Edge Driver - Microsoft Edge Developer
Close the loop on your developer cycle by automating testing of your website in Microsoft Edge with Microsoft Edge Driver
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
我下载的是和我的浏览器版本相同的。
代码:
public class test
{
public static void main(String[] args)
{
System.setProperty("webdriver.edge.driver", "D:\\JAVA代码\\eage驱动\\新建文件夹\\msedgedriver.exe");
EdgeDriver driver = new EdgeDriver();
}
}
错误信息:
错误信息:
11月 01, 2021 8:49:06 下午 org.openqa.selenium.os.OsProcess checkForError
严重: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "D:\JAVA代码\eage驱动\新建文件夹\msedgedriver.exe" (in directory "."): CreateProcess error=216, 该版本的 %1 与你运行的 Windows 版本不兼容。请查看计算机的系统信息,然后联系软件发布者。)
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:17:03'
System info: host: 'HUANGWEIMIN', ip: '192.168.27.59', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16.0.2'
Driver info: driver.version: EdgeDriver
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.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:96)
at test.main(foure.java:294)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:3318/status] to be available after 20013 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:197)
... 8 more
Caused by: java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 9 more
进程已结束,退出代码为 1