trai bui
trai bui

Reputation: 598

MicrosoftWebDriver loading web driver null

I have the error when run selenium on local machine which is Windows 10 Enterpise 64-bit (Microsoft Edge Version: 25.10586.672.0)and Microsoft WebDriver - Release 10240. My Selenium version is: 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() {
       }
}

When I run code it open the Edge Browser and has error:

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

Upvotes: 1

Views: 962

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193108

You may consider to look into the Release Notes as it mentions:

Updating .NET bindings to not send incorrect W3C Firefox capabilities Previously, RemoteWebDriver would send the same capabilities dictionary using both the "desiredCapabilities" and "capabilities" properties when requesting a new remote session. In the case of the language bindings expressly requesting to use the legacy Firefox driver, the capabilities dictionary will include properties that are invalid for the W3C-compliant remote server. To resolve that issue, we will mask the explicit attempt by setting a property that causes the .NET RemoteWebDriver to send a legacy-only compatible new session request when explicitly requesting the legacy driver.

I don't see any significant error as such in your code except one, to see NoSuchSessionException. Instead of:

DesiredCapabilities capabilities = DesiredCapabilities.edge();

You should use:

DesiredCapabilities cap = new DesiredCapabilities();

Upvotes: 2

Damian Jansen
Damian Jansen

Reputation: 236

It's possible you also need to start a driver service, i.e.

service = new EdgeDriverService.Builder()
    .usingDriverExecutable(new File("path/to/my/MicrosoftWebDriver.exe"))
    .usingAnyFreePort()
    .build();
service.start();

Have a look at this example of an EdgeDriver.

Upvotes: 0

Related Questions