Selenium webdriver launching edge browser

2019-09-05 17:54发布

问题:

I have an issue with Edge browser below is my code.The browser opens but control never goes to the browser instead execution halts and shows the error

service = new EdgeDriverService.Builder()
    .usingDriverExecutable(new File("C:\\Program Files (x86)\\Microsoft Web     Driver\\MicrosoftWebDriver.exe"))
         .usingAnyFreePort()
         .build();
          service.start();
          driver = new EdgeDriver(service, DesiredCapabilities.edge());

          driver.get("http://xyz.in");

On executing the line driver = new EdgeDriver(service, DesiredCapabilities.edge()); edge browser is getting launched after that execution is failing with the error as

'FAILED: test
    org.openqa.selenium.remote.SessionNotFoundException: null (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 1.98 seconds
    Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
    System info: host: 'ODERWin10', ip: '192.168.1.119', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_13'
    Driver info: org.openqa.selenium.edge.EdgeDriver
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:164)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
        at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:152)
        at Pack1.CrossBrowserTest.test(CrossBrowserTest.java:36)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)'

Please suggest a solution, thanks in advance

回答1:

Selenium 2.48.2 recognizes Windows 10 as Windows 8, i get the same error. The only way I've been able to get Edge to open and not hang is to manually open the MicrosoftWebDriver.exe file, and input whatever URL it tells me it's listening on:

DesiredCapabilities browser = DesiredCapabilities.edge();
browser.setBrowserName(DesiredCapabilities.edge().getBrowserName());
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:17556"), browser);


回答2:

I had the same problem with SessionNotFoundException

  • Be sure to use the latest WebDriver for Windows Insiders from here https://www.microsoft.com/en-us/download/details.aspx?id=48740 (the normal one from here https://www.microsoft.com/en-us/download/confirmation.aspx?id=48212 does not work anymore on newer Windows 10 builds than 10240)
  • The 'Windows 8' display problem is as far as I know only a wrong output and not the root of the issue. Nonetheless it is fixed in selenium 2.49.0 (it's bug #669)


回答3:

The problem is that you are trying to use Edge on a system in which it is not installed.

As told here :

 System info: host: 'ODERWin10', ip: '192.168.1.119', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_13'

You are on Windows 8.

Edge is only supported and available on Windows 10.

You need to use a Windows 10 machine to run you test.