Search code examples
pythonunit-testingselenium-webdriverselenium-chromedriverchrome-for-testing

Appearance of the “Chrome For Testing” mention when using chromedriver for my Selenium Python Project


I've been using Python Selenium for a long time and when I initialize a driver to browse any site, a chrome window opens with a banner at the top indicating that the instance “Chrome is controlled by automated testing software”.

I'm currently working on a scraper project that collects data from a site. Everything worked fine. I had managed to make a stable and fast scraper. I then wanted to test my functions with unittest. Once I'd finished creating my unit tests, I began to notice that their results weren't regular and could change from one execution to the next. I then launched the scraper to check that everything was working, but this was no longer the case.

I noticed that the instance opened by the Selenium driver was no longer a “Chrome” instance but a “Chrome for Testing” instance (with a different logo than usual) and that a new mention appeared at the top of the page in addition to the existing one: “Chrome for Testing v125.0.6422.60 is reserved for automated testing. For normal browsing, ...” I also noticed that this browser was much slower for navigation through the site, which explained the problems I'd been having. I haven't changed anything apart from adding unit tests and I don't understand why this has changed.

I first tried to remove the test part of my project, which didn't help. I also checked the driver version, which hadn't changed since I downloaded it a year ago. I checked the Chrome version, which hadn't evolved between the time I started having this problem and the time everything was working properly (i.e. a 24-hour interval).

Thanks in advance to anyone who can help !


Solution

  • Not sure what you are referring to. The standard chromedriver still launches chromedriver.exe, has the same icon as vanilla chrome, and is called Chrome. Your Chrome browser should have updated several times in the last year. My guess is that you've installed some other browser. I would uninstall all instances of Chrome, Chrome for Testing, and other browsers. Then go to the official Chrome site and download the latest version.

    As of Selenium 4.6, SeleniumManager was added to Selenium and it automatically takes care of downloading and configuring the appropriate driver for you. So, you no longer need to use a DriverManager or specify the path, etc.

    Your basic code to launch the browser and start Selenium now looks like

    from selenium import webdriver
    
    URL = "https://www.google.com"
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get(URL)