3

Chrome version: 68.0.3440.106
Chrome webdriver version: ChromeDriver 2.41.578737
Python Version : Python 3.5.2

I write this code in python:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


o = webdriver.ChromeOptions()
o.add_argument("disable-extensions");
o.add_argument("--start-maximized");
driver = webdriver.Chrome(executable_path=r"chromedriver.exe",options=o)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

after few seconds chrome opened with this error:


and nothing happend till i close chrome and get this exception:

    Traceback (most recent call last):
  File ".../game.py", line 8, in <module>
    driver = webdriver.Chrome(executable_path=r"chromedriver.exe",options=o)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 251, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "...\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited normally
  (unknown error: unable to discover open pages)
  (The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.17134 x86_64)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
assaf.b
  • 124
  • 1
  • 1
  • 10

7 Answers7

1

use correct argument for disabling extension:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
o = Options()
#o.add_argument("--disable-extensions"); #here
o.add_experimental_option("useAutomationExtension", false); #you can try this as well
o.add_argument("--start-maximized");
driver = webdriver.Chrome(executable_path=r"chromedriver.exe",chrome_options=o)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
theGuy
  • 683
  • 5
  • 15
  • you can try one more option: o.setExperimentalOption("useAutomationExtension", false); This capability will help to not load Chrome Automation extension. I have updated my answer. – theGuy Aug 24 '18 at 18:41
  • still didn't work, in python is `o.add_experimental_option("useAutomationExtension", False)` – assaf.b Aug 24 '18 at 19:09
  • my bad, you are right. I mixed up python and java. Btw are you still getting same error? – theGuy Aug 24 '18 at 19:10
1

Today I was the same trouble and I fixed using:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


o = webdriver.ChromeOptions()
o.add_argument("disable-extensions")
o.add_argument("--start-maximized")
o.binary_location = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ## This line define path of browser. In this case, Google Chrome
driver = webdriver.Chrome(executable_path=r"chromedriver.exe",options=o)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Lucas Tula
  • 11
  • 1
  • 1
    Can you explain which part you changed to fix this issue? – Oliver.R Apr 15 '20 at 23:08
  • Oliver, add this line: o.binary_location = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ## This line define path of browser. In this case, Google Chrome – Lucas Tula Apr 16 '20 at 11:41
1

I recently had this issue using TeamCity, which was caused by chrome (and chromedriver) not shutting down after executing my script. inserting "taskkill /f /im chrome.exe" and "taskkill /f /im chromedriver.exe" fixed this issue.

Gerdes88
  • 25
  • 4
0

This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited normally
  (unknown error: unable to discover open pages)
  (The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

Your main issue seems that the chrome binary i.e. chrome.exe and the associated files are no more available/accessible from the default location of:

C:\Program Files (x86)\Google\Chrome\Application\

The possible reasons are:


Additional considerations

  • Chrome and ChromeDriver are present in the desired location.
  • Chrome and ChromeDriver are having executable permission for non-root (non-administrator) users.
  • Upgrade Selenium to current levels Version 3.14.0.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as a non-root user.
  • Run the selenium server with webdriver-manager start from the machine with the desktop (don't use a remote session to start the selenium server).
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • The chrome was opened but after I close the window (after alot of time without any response but the error massage) I get this exception, your answer doesn't help me at all, but thanks for the try. – assaf.b Aug 25 '18 at 07:53
0

In case anyone is here now, I had this same issue and I passed --no-sandbox argument and it worked. Give it a shot.

chrome_options.add_argument('--no-sandbox')
mustafa
  • 36
  • 5
0
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
o = Options()
o.add_argument('--no-sandbox')
driver = webdriver.Chrome(executable_path=r"chromedriver.exe",chrome_options=o)

It worked for me.

  • Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the [help center](https://stackoverflow.com/help/how-to-answer). – moken Apr 07 '23 at 01:41
-1

We faced this issue using Java, Cucumber, Maven, Serenity, and IntelliJ. After trying everything the solution was so easy:

Just run IntelliJ as administrator.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33860092) – Wakeme UpNow Feb 22 '23 at 02:40