Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Python Selenium Webdriver to open Electron Application

I've been attempting to bypass using Spectron for End2End testing an electron application by leveraging my experience with Selenium Webdriver on Python. Using a combination of the Chromedriver get started page, and several resources that seem to suggest its possible, this is what I came up with:

from selenium import webdriver
import selenium.webdriver.chrome.service as service
servicer = service.Service('C:\\browserDrivers\\chromedriver_win32\\chromedriver.exe')
servicer.start()
capabilities = {'chrome.binary': 'C:\\path\\to\\electron.exe'}
remote = webdriver.remote.webdriver.WebDriver(command_executor=servicer.service_url, desired_capabilities = capabilities, browser_profile=None, proxy=None, keep_alive=False

The issue is that instead of opening the electron application, it opens a standard instance of Chrome.

Most of resources I've seen have been several years old so something may have changed to make it no longer possible.

Does anyone know of a way to use Python Selenium WebDriver to test an Electron application?

like image 928
Yoni Shurygin Avatar asked Sep 08 '17 00:09

Yoni Shurygin


1 Answers

Below works great for me

from selenium import webdriver


options = webdriver.ChromeOptions()
options.binary_location = "/Applications/Electron.app/Contents/MacOS/Electron"

driver = webdriver.Chrome(chrome_options=options)

driver.get("http://www.google.com")


driver.quit()
like image 109
Tarun Lalwani Avatar answered Nov 18 '22 22:11

Tarun Lalwani