You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
As the title says, I am trying to make a GUI with a simple button to start and close a WebDriver. When it is open, the WebdDriver performs some tasks for an indefinite time. When the user wants to stop the process, he just clicks on the button to close it and return to the GUI.
I've read a few issues and Stackoverflow pages on similar topics, but none of them helped me in this case.
Here is the code I use, I removed the part about multiprocessing/threading/pool because none of them work.
main.py
#!usr/bin/pythonimporteelfromseleniumimportwebdriverfromselenium.webdriver.chrome.serviceimportServiceasSCfromwebdriver_manager.chromeimportChromeDriverManagerasCDM@eel.exposedefopen():
"""Open the webdriver in a parallel process."""defweb():
globaldriverdriver=webdriver.Chrome(service=SC(CDM(log_level=0).install()))
# Does its tasks.@eel.exposedefclose():
"""Stop the webdriver from the parallel process."""if__name__=='__main__':
eel.init('.')
eel.start('index.html')
The files are in the same directory.
I'm using Windows 11 with the latest version of the ChromeDriver and the latest version of the eel module on Python 3.9.9.
The text was updated successfully, but these errors were encountered:
Disclaimer:
I have no used the project extensively enough to be able to advise with confidence.
All tips in here are just attempts at providing some pointers since I saw that the project is semi-abandoned
as per this GitHub issue: #600
Assumptions
eel behaves somewhat a little like selenium in that the web driver is not a python process
eel has an event loop which keeps the application running
eel has interrupt mechanism for functions that are being called from javascript/browser side
First Idea
Use psutil python module to kill the new instance/window and kill it when done. trap the exception in python code.
not clean but might get you there.
Considerations:
Based on point 1, it would mean that stopping a full window may not be possible without 'killing' the driver.
If it's like selenium, doing so would destroy all instances of eel or the browser at once, making my first idea no viable.
Second Idea
Once again assuming it's like selenium you might be able to create a new 'tab' in the browser, which you can also detach.
The important part is that by doing so you would be retaining independent control of each "window" and effectively be able to easily kill it using regular eel controls.
How would you be able to monitor once detached I don't know, maybe via a sub-process...
Hello, thank you for you answer :) I tried the first option and it works great.
I used the terminate() method to stop the process and then I kill all the processes of the webdriver using psutil.
Hello,
As the title says, I am trying to make a GUI with a simple button to start and close a WebDriver. When it is open, the WebdDriver performs some tasks for an indefinite time. When the user wants to stop the process, he just clicks on the button to close it and return to the GUI.
I've read a few issues and Stackoverflow pages on similar topics, but none of them helped me in this case.
Here is the code I use, I removed the part about multiprocessing/threading/pool because none of them work.
main.py
index.html
The files are in the same directory.
I'm using Windows 11 with the latest version of the ChromeDriver and the latest version of the
eel
module on Python 3.9.9.The text was updated successfully, but these errors were encountered: