1

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:

  1. 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?

  1. 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.
9
  • I am not sure if detach works. Although this link is about Chrome, but I think it could be extrapolated to Edge too. Would this help for your 2nd query? SO archive link Commented Jan 21, 2022 at 12:08
  • Don't .quit()/.close() the driver... problem solved.
    – JeffC
    Commented Jan 21, 2022 at 18:58
  • @Anand Gautam Hey thanks for sharing those. Actually, I have created this question only after referring to those links. Sadly, detach is not working. When I close the driver window, the browser window closes too. And I am not able to open the browser window without opening the driver window. If there's a way to open the browser without opening the driver window on screen (background is fine), or if there's a way to close the driver and convert the browser to a normal browser, that's what I need.
    – Veki
    Commented Jan 24, 2022 at 13:45
  • 1
    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"]).
    – Yu Zhou
    Commented Jan 25, 2022 at 9:49
  • 1
    @Meet I'm glad to help. I've posted it as an answer.
    – Yu Zhou
    Commented Jan 26, 2022 at 1:30

1 Answer 1

2

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"])

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.