Issue
I am using selenium through python to automate a task - open a webpage, enter some text, click a button.
Now, once this is done, I want the browser to stay open and all the python files, the edgedriver.exe cmd window, and any other process ran by the python script to close. I want the browser to be loaded like a normal browser that we load manually.
My query:
- Can we stop the browser from closing when I close python program as well as the edgebrowser.exe? I have added this to my code, but this doesn't stop browser from closing once all other windows are closed.
code:
from selenium.webdriver.edge.options import Options
edge_options = Options()
edge_options.add_experimental_option("detach", True)
Using the detach option, I may be able to keep browser running with python closed. But I also do not want the edgebrowser.exe command window on the screen. Can we do that?
- Can we remove that line below the address line saying "Your browser is being controlled by an automation test software". I want the browser window to look like it does when we open it using the app/program shortcut.
Solution
You can refer to this link to hide the command window. The code only works on selenium version 4.0.0 or higher.
To remove the line "Your browser is being controlled by an automation test software", you can try to add these lines of code:
edge_options.add_argument("--remote-debugging-port=9222")
edge_options.add_experimental_option('useAutomationExtension', False)
edge_options.add_experimental_option("excludeSwitches", ["enable-automation"])
Answered By - Yu Zhou
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.