Nov-19-2018, 10:57 AM
I am writing codes to do web crawling in windows environment, and using google chrome and mozila firefox as browser. For google chrome I downloaded latest chromedriver and the latest geckodriver for firefox and added path of these drivers in the environment variables.
A sample code is given below which I am executing for google chrome -
A sample code is given below which I am executing for google chrome -
from selenium import webdriver driver = webdriver.Chrome("C:\\ChromeDriver\\chromedriver.exe") driver.get("https://www.google.com")In this case the web browser is opening but the google page didn't opened and the whole page remains white after staying like this for certain times the below error is coming. The image of the browser is attached.
Error:c:\ChromeDriver>python sparrow.py
[4064:8324:1119/150817.243:ERROR:install_util.cc(691)] Failed to read HKLM\SOFTWARE\Policies\Google\Chrome\MachineLevelUserCloudPolicyEnrollmentToken: The system cannot find the file specified. (0x2)
DevTools listening on ws://127.0.0.1:50164/devtools/browser/f68ff514-1e83-403b-b8a3-61adfc50b15d
Traceback (most recent call last):
File "sparrow.py", line 3, in <module>
driver = webdriver.Chrome("C:\\ChromeDriver\\chromedriver.exe")
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-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: chrome not reachable
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.17134 x86_64)
The below code is for the firefox -from selenium import webdriver driver = webdriver.Firefox("C:\\ChromeDriver\\") driver.get("https://www.google.com")I am not getting any output after executing the code, even the browser is not also opening. After some time this error message has been thrown.
Error:Traceback (most recent call last):
File "sparrow.py", line 3, in <module>
driver = webdriver.Firefox("C:\\ChromeDriver\\")
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Users\CSURV5\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 104, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver
Please let me know the exact reason, why I am getting these error?