Tom
Tom

Reputation: 21

Testing electron applications: unable to initialize test as prescribed with Robot Framework

I am attempting to test a packaged Electron application (an .exe) with RobotFramework on a windows 10 machine. I have other RobotFramework tests for other web applications that are running fine on the same machine.

I have the chromedriver of what I believe to be the correct version within the same directory as my .robot script. I have also tried different version of the chromedriver.exe. Currently I am using chromedriver 80.0.3987.16 The package.json of my app indicates that the electron version is 5.0.1

I have created a vars.py file and have the robot script instantiate the driver with the code as indicated in https://spage.fi/electron

As prescribed by the spage.fi link: within the vars.py file:

binary_location = {"chromeOptions": {"binary": "myelectronapp.exe"}}   

Note that the .exe and its associated files from the package process I've included in the same directory as the robot script in order to remove any path dependancies.

My robot snippet:

*** Settings ***
Documentation    Suite description
Library          SeleniumLibrary
Variables        vars.py

*** Test Cases ***
Test title
    [Tags]    DEBUG
    Log To Console    calling create driver
    Create Webdriver    Remote    desired_capabilities=${binary_location} command_executor=http://localhost:9515

My port 9515 is open via an inbound rule.

My experience has been regardless of the chromedriver version that I think aligns, that I always get a connection refusal error:

[ WARN ] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000000003E3C160>: Failed to establish a new connection: [WinE
rror 10061] No connection could be made because the target machine actively refused it')': /session

x 3 retries

I'm figuring it is not a port accessibility issue because when I run chromedriver from the command line and then invoke the url at port 9515, I get the callback trace that I would expect.

Its difficult to know if this is from a syntax issue or some other connection attribute that I have overlooked.

Upvotes: 1

Views: 523

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193088

This error message...

[ WARN ] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000000003E3C160>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')': /session

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.


Your main issue is the incompatibility between the version of the binaries you are using as follows:

Supports Chrome version 80

Supports Chrome 79

So there is a clear mismatch between the ChromeDriver v80.0 and the Chrome Browser v79.0


Solution

Ensure that:

  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is downgraded to ChromeDriver v79.0 level.
  • Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it and install the recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Upvotes: 0

Related Questions