so currently we are using Electron for our application and I am trying to use the selenium library for it in Robot framework but I encountered 2 errors.
In my StartElectron.robot file, I have these:
*** Settings ***
Library RPA.Browser.Selenium
Library RPA.JSON
*** Variables ***
${portNumber}= 9515
*** Keywords ***
Start WebDriver Service
${port} Convert To Integer ${portNumber}
${service}= Evaluate sys.modules['selenium.webdriver'].chrome.service sys
${service} CallMethod ${service} Service C:/Drivers/chromedriver.exe port=${port}
Call Method ${service} start
Open Electron App
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${options} add_argument --remote-debugging-port=7070
Call Method ${options} add_argument --no-sandbox
${options.binary_location} Set Variable C:/Users/Mozi/AppData/Local/Programs/dev2/dev2.exe
Create Webdriver Remote command_executor=127.0.0.1:${portNumber} options=${options}
Enter username
Wait Until Page Contains Element id:login-username
Click Element id:login-username
Input Text id:login-username dev2_encoder_1
Then on my TC1_Login.robot:
*** Settings ***
Library RPA.Browser.Selenium
Library RPA.JSON
Resource ../../StartElectron1.robot
*** Test Cases ***
Login Encoder user
Start WebDriver Service
Open Electron App
Enter username
When I try to run my test case, electron app will open but I always receive this error:
[27464:0812/143225.154:INFO:CONSOLE(0)] "Uncaught (in promise) TypeError: Failed to fetch", source: file:///C:/Users/Mozi/AppData/Local/Programs/dev2/resources/app.asar/build/service-worker.js (0)
and the
NoSuchWindowException: Message: no such window: window was already closed error.
The no such window error I think might be because whenever our electron app starts, it will start with a window that has the company logo then it will close the window and open again a new window quickly for the login page (this happens within 1-2 seconds), so I tried the built in Sleep
and also Wait Until Page Contains Element id:login-username
but I still receive the no such window error.
Any ideas on how I can resolve these errors? All help is greatly appreciated. Thanks!