Skip to content Skip to sidebar Skip to footer

Javascript Selenium Webdriver With Edge Typeerror: Cannot Read Property 'start' Of Null

I'm trying to set up selenium-webdriver example using Javascript and Microsoft Edge. In any other browser this code below works. But Edge won't start. I tried to find a solution, b

Solution 1:

This line triggers the error:

new Builder().forBrowser('MicrosoftEdge').build();

Cannot read property 'start' of null actually says: "I don't know what MicrosoftEdge is". Basically, in some instances, selenium expects one of: "firefox", "edge" (instead of "MicrosoftEdge"), "chrome", etc

Now

The main topic:

Do not know how to build driver: edge; did you forget to call usingServer(url)?

This can happen due to many reasons:

  1. Is edge installed?
  2. Do you have the latest MicrosoftEdgeDriver server.?
  3. Is MicrosoftEdgeDriver is on your PATH?

If you answer yes to all of the above, then behind the scenes, while building, selenium didn't get the expected capabilities, and, for a last attempt, tries to connect to a remote webDriver (that's why it says usingServer)

As such, to solve this, you can try building the driver yourself, like this:

var edge = require('selenium-webdriver/edge');

var service = new edge.ServiceBuilder()
    .setPort(55555)
    .build();

var options = new edge.Options();
// configure browser options ...var driver = edge.Driver.createSession(options, service);

And then you can continue with driver.get('http://www.google.com/ncr'); etc.

Solution 2:

The reason for the error is: webdriver is looking for Edge Service to start while creating edge session and it find it to null(as its not set).

The simple solution is create Edge service using Edge drive path.

const {Builder, By, Key, until} = require('selenium-webdriver');
    const edge = require('selenium-webdriver/edge');
    const edgedriver = require('edgedriver');   //If this driver is already on your system, then no need to install using npm.

    (asyncfunctionexample() {
        let service = awaitnew edge.ServiceBuilder(edgedriver.path);
        let driver = awaitnewBuilder.forBrowser('MicrosoftEdge').setEdgeService(service).build();

        try {
            await driver.get('http://www.google.com/ncr');
            //...............//...............
        } finally {
            await driver.quit();
        }
    })();

Post a Comment for "Javascript Selenium Webdriver With Edge Typeerror: Cannot Read Property 'start' Of Null"