question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

latest selenium-webdriver no longer works with electron

See original GitHub issue

🐛 Bug Report

Running tests in electron using latest selenium-webdriver no longer works in selenium-webdriver 4.0.0-beta.1. They result in

(node:20272) UnhandledPromiseRejectionWarning: SessionNotCreatedError: session not created: No matching capabilities found
    at Object.throwDecodedError (C:\Downloads\MyCode\node_modules\selenium-webdriver\lib\error.js:517:15)
    at parseHttpResponse (C:\Downloads\MyCode\node_modules\selenium-webdriver\lib\http.js:671:13)
    at Executor.execute (C:\Downloads\MyCode\node_modules\selenium-webdriver\lib\http.js:597:28)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

This used to work with selenium-webdriver 3.4.0. I am unsure whether this should be resolved in selenium, electron or chromedriver. Any input is appreciated.

To Reproduce

Detailed steps to reproduce the behavior:

Expected behavior

I was hoping testing with electron would still work.

Test script or set of commands reproducing this issue

const ChildProcess = require('child_process');
const chromedriver = require('chromedriver');

const chromedriverProcess = ChildProcess.spawn(
    chromedriver.path, // process path goes here
    [], // arguments go here
    {
        stdio: 'inherit'
    }
);
const electronBinary = 'MyElectronBinary.exe';
const driver = new webdriver.Builder()
    // The "9515" is the port opened by chrome driver.
    .usingServer('http://localhost:9515')
    .withCapabilities({
        chromeOptions: {
            // Here is the path to your Electron binary.
            binary: electronBinary
        }
    })
    .forBrowser('electron')
    .build();

driver.get('http://www.google.com');
driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.name('btnG')).click();
driver.wait(() => {
    return driver.getTitle().then((title) => {
        return title === 'webdriver - Google Search';
    });
}, 1000);

driver.quit();

Environment

OS: Windows 10.0.19042 Build 19042 Browser: electron (chromedriver) Browser version: electron 10.1.3 Browser Driver version: 85.0.4183.38 (9047dbc2c693f044042bbec5c91401c708c7c26a-refs/branch-heads/4183@{#779}) Language Bindings version: nodejs 12.14.1 Selenium Grid version (if applicable): /

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kr3lcommented, Mar 16, 2021

Thanks Diego! It indeed works when changing to “goog:chromeOptions” and “forBrowser(‘chrome’)”!

0reactions
diemolcommented, Mar 16, 2021

Ok, so not sure if this is an Electron or ChromeDriver issue, but I was able to run a small script and have things working. The main change, aside of being sure the ChromeDriver version is the right one for the Electron app, was: .forBrowser('chrome')

Complete setup can be seen here.

I am going to close this and keep an eye on https://github.com/electron/electron/issues/28197 in case something is needed on the Selenium WebDriver side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron not compatible with latest selenium-webdriver #28197
The instructions work for selenium-webdriver 3.4.0, but no longer work for more recent versions of selenium-webdriver, like selenium-webdriver 4.0.0-beta.1. I ...
Read more >
Selenium webdriver not working in Electron build
1 Answer 1 ... Then in the terminal, check for this error: The ChromeDriver could not be found on the current PATH. Please...
Read more >
Selenium and WebDriver - Electron
WebDriverJs provides a Node package for testing with web driver, we will use it as an example. 1. Start ChromeDriver​. Zuerst müssen Sie...
Read more >
Spotlight on Rapise 7.3: New Selenium Based Recording for ...
Rapise 7.3 includes our new Selenium WebDriver based Recorder and a major upgrade of the Selenium WebDriver downloading and configuration ...
Read more >
ChromeDriver is not compatible with the installed Chrome ...
message is shown when Chrome browser and Selenium driver (a selenium ... please open the chrome web driver download page and find a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found