'Testing an electron application through pytest-selenium

I have a small node/electron application to test.

It's just run locally with "npm start", which brings up a small electron browser with the application.

How can I test this with pytest-selenium, given that I have no url to give it?

Ideally I would prefer to use the selenium fixture.

Here is what I have so far.

def test_sanity(install_cbm_dash, install_dir):

    from selenium import webdriver

    # Start the web driver
    web_driver_path = "C:\\webdrivers\\chromedriver.exe"
    service = webdriver.chrome.service.Service(web_driver_path)
    service.start()

    # start the app
    web_driver = webdriver.remote.webdriver.WebDriver(
        command_executor=service.service_url,
        desired_capabilities={
            'browserName': 'chrome',
            'goog:chromeOptions': {
                'args': [],
                'binary': "path_to_electron_exe",
                'extensions': [],
                'windowTypes': ['webview']},
            'platform': 'ANY',
            'version': ''},
        browser_profile=None,
        proxy=None,
        keep_alive=False)

This opens up an electron window, but not the app in question. How do I direct it to open the actual application?

I am thinking I need to specify the path to the project itself to electron, but I don't know how to do this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source