在 Windows 10 Enterprise 64 位(Microsoft Edge 版本:25.10586.672.0)和 Microsoft WebDriver - Release 10240 的本地计算机上运行 selenium 时出现错误。我的 Selenium 版本是:3.6.0
public class SeleniumTest {
private WebDriver driver;
@BeforeClass
public void getWebDriver() {
try {
System.setProperty("webdriver.edge.driver", "myapp/driver/MicrosoftWebDriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.edge();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "eager");
capabilities.setPlatform(Platform.WIN10);
capabilities.setBrowserName(BrowserType.EDGE);
capabilities.setVersion("");
driver = new EdgeDriver(capabilities);
} catch (Exception e) {
e.printStackTrace();
}
driver.get(Constant.URL);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
}
@AfterClass
public void quitDriver() throws InterruptedException {
Thread.sleep(3000);
driver.quit();
}
@Test ()
public void aTest() {
}
@Test ()
public void bTest() {
}
}
当我运行代码时,它会打开 Edge 浏览器并出现错误:
org.openqa.selenium.NoSuchSessionException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 873 milliseconds
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'computername', ip: 'myip', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: EdgeDriver