Chrome binary Error after new OS - Linux Mint installation - python

I have installed new Linux Mint in my computer.
I have installed Github, pycharm. I downloaded the code.
As per the packages requirement, i have installed the Selenium and other packages.
The code below which was working in previous Ubuntu Linux
Now it is downloading the code and its not working properly.
It is throwing the error.
For the first time, it is downloading the driver. Second time it is giving this error.
Both times the code is not working.
Please help me.
code:-
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
s = Service(ChromeDriverManager().install())
chrome_options = Options()
chrome_options.add_experimental_option("detach",True)
"""
The browser will be started.
"""
browser = webdriver.Chrome(service=s, options=chrome_options)
browser.maximize_window()
browser.get("https://rahulshettyacademy.com")
print(browser.title)
browser.get("https://rahulshettyacademy.com/angularpractice/")
print(browser.title)
Error message:-
/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/26092022_selenium1.py
Traceback (most recent call last):
File "/home/halovivek/PycharmProjects/yearcoding/26092022_selenium1.py", line 13, in <module>
browser = webdriver.Chrome(service=s, options=chrome_options)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
#0 0x55d1d6012693 <unknown>
#1 0x55d1d5e0bb0a <unknown>
#2 0x55d1d5e2e46e <unknown>
#3 0x55d1d5e2c1f4 <unknown>
#4 0x55d1d5e67953 <unknown>
#5 0x55d1d5e61743 <unknown>
#6 0x55d1d5e37533 <unknown>
#7 0x55d1d5e38715 <unknown>
#8 0x55d1d60627bd <unknown>
#9 0x55d1d6065bf9 <unknown>
#10 0x55d1d6047f2e <unknown>
#11 0x55d1d60669b3 <unknown>
#12 0x55d1d603be4f <unknown>
#13 0x55d1d6085ea8 <unknown>
#14 0x55d1d6086052 <unknown>
#15 0x55d1d60a071f <unknown>
#16 0x7f5a5a21a1da <unknown>
#17 0x7f5a5a2a2d84 <unknown>
Process finished with exit code 1
Modified the code as per advice .
import os
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.firefox import GeckoDriverManager
#options = Options()
options = webdriver.FirefoxOptions()
options.binary_location = r"/usr/bin/"
options.add_argument("start-maximized")
options.add_experimental_option("detach", True)
service = FirefoxService(log_path=os.devnull,)
browser = webdriver.Firefox(service= FirefoxService(GeckoDriverManager().install()), options=options)
#browser = webdriver.Firefox(service=service,options=options,)
capabilities = webdriver.FirefoxOptions().to_capabilities()
options.set_capability("cloud:options", capabilities)
browser.maximize_window()
browser.implicitly_wait(5)
browser.get("https://the-internet.herokuapp.com/windows")
print(browser.title)
Still error exist:-
/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/27092002_selenium3.py
[WDM] - Downloading: 16.2kB [00:00, 11.9MB/s]
Traceback (most recent call last):
File "/home/halovivek/PycharmProjects/yearcoding/27092002_selenium3.py", line 15, in <module>
browser = webdriver.Firefox(service= FirefoxService(GeckoDriverManager().install()), options=options)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 177, in __init__
super().__init__(
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
Process finished with exit code 1

Similar to Selenium gives "unknown error: cannot find Chrome binary" when running chrome driver on Ubuntu , it means that either Chrome is not installed on your system, or it's not installed in the default location where it would be found on your PATH. If Chrome is installed, but in a special location, you can set it like this (after you put in a valid path):
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = "/PATH/TO/YOUR/CHROME"
driver = webdriver.Chrome(chrome_options=options)
If Chrome isn't installed at all on your Linux machine, you can try existing solutions such as https://stackoverflow.com/a/62234251/7058266 or https://www.digitalocean.com/community/tutorials/install-chrome-on-linux-mint in order to install it into the default location on your PATH.
Here's an example of Firefox headless mode on Linux:
import os
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
capabilities = webdriver.FirefoxOptions().to_capabilities()
capabilities["moz:firefoxOptions"] = {"args": ["-headless"]}
options.set_capability("cloud:options", capabilities)
service = FirefoxService(
log_path=os.devnull,
)
driver = webdriver.Firefox(
service=service,
options=options,
)
### Do things here ###
driver.quit()

Related

How to Fix Python Selenium Error: 'No Chrome Binary at ...'

I'm trying to run the below code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.binary_location = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
driver = webdriver.Chrome(service = Service(ChromeDriverManager().install()), options = options)
EDIT
I'm not sure I'm supposed to pass the chrome drive or the actual chrome app as the options argument, but even if I set either of the below (two different locations I have the chrome driver in) I still get the exact same message.
options.binary_location = "C:\\Program Files (x86)\\chromedriver.exe"
options.binary_location = "C:\\Users\\Tom\\Projects_Python\\Instagram_Image_Scraper\\chromedriver.exe"
I get the below error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 80, in __init__
super().__init__(
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 104, in __init__
super().__init__(
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/mnt/c/Users/Tom/Projects_Python/Instagram_Image_Scraper/env/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at C:\Program Files\Google\Chrome\Application\chrome.exe
Stacktrace:
#0 0x56380af48d93 <unknown>
#1 0x56380ad172d7 <unknown>
#2 0x56380ad3d3b2 <unknown>
#3 0x56380ad3ba3d <unknown>
#4 0x56380ad804f4 <unknown>
#5 0x56380ad77353 <unknown>
#6 0x56380ad46e40 <unknown>
#7 0x56380ad48038 <unknown>
#8 0x56380af9c8be <unknown>
#9 0x56380afa08f0 <unknown>
#10 0x56380af80f90 <unknown>
#11 0x56380afa1b7d <unknown>
#12 0x56380af72578 <unknown>
#13 0x56380afc6348 <unknown>
#14 0x56380afc64d6 <unknown>
#15 0x56380afe0341 <unknown>
#16 0x7f1c05443609 start_thread
My chrome version is: Version 110.0.5481.97 (Official Build) (64-bit)
Machine: Windows 11
I tried to assign the Chrome web driver to the variable 'driver' but it's giving me an error, I'm expecting to pass a web driver to the 'driver' variable so I can start pulling and scraping web pages.
Alternatives tried:
I tried to use a raw string to pass the chrome application location into the web driver, but this didn't work.
I tried to use the Firefox driver, but I see a similar issue about not having a binary.
Can anyone please help?
Try forward slash(//) instead of backslash(\) as below:
options.binary_location = "C://Program Files//Google//Chrome//Application//chromedriver.exe"
Try by passing the chromedriver.exe rather than chrome.exe
options.binary_location = "<full path here>//chromedriver.exe"
In case you do not have a chrome driver, here is the download link

Python Selenium Webdriver is not working in headless mode

Unable to create Python Chrome WebDriver in headless mode.
I am using Chrome version 108.0.5359.94.
I am also using the Service(ChromeDriverManager().install()) to automatically install the compatible chromewebdriver.
NOTE: The same result happens if I download the applicable chrome webdriver and instead of using the service I use the executable_path.
The code for recreating this is very simple.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = Options()
# chrome_options.add_argument('--headless')
chrome_options.add_argument('--remote-debugging-port=9222')
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
print(driver)
When running in regular (not headless) mode I am getting the expected print of the webdriver object:
python selenium_test.py
<selenium.webdriver.chrome.webdriver.WebDriver (session="9b6ec32017d8d864f8e2061293faee40")>
But when running in headless mode (same code simply remove the marker from the headless option line), I am getting the following error:
python selenium_test.py
Traceback (most recent call last):
File "/home/boazz/PycharmProjects/pythonProject/selenium_test.py", line 10, in <module>
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x5588159a82a3 <unknown>
#1 0x558815766f77 <unknown>
#2 0x55881578f5f7 <unknown>
#3 0x55881578b7d0 <unknown>
#4 0x5588157cc0b7 <unknown>
#5 0x5588157cba5f <unknown>
#6 0x5588157c3903 <unknown>
#7 0x558815796ece <unknown>
#8 0x558815797fde <unknown>
#9 0x5588159f863e <unknown>
#10 0x5588159fbb79 <unknown>
#11 0x5588159de89e <unknown>
#12 0x5588159fca83 <unknown>
#13 0x5588159d1505 <unknown>
#14 0x558815a1dca8 <unknown>
#15 0x558815a1de36 <unknown>
#16 0x558815a39333 <unknown>
#17 0x7fa6443c0b43 <unknown>
I expected the chrome driver to be created regardless if I am using the headless option or not. What could be the cause for that?
The issue here is with a port you trying to set for debugging.
I tried your code and it did not work for me too, but when I changed the port from 9222 to 61625 it worked.
So, at least for me this worked:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
options = Options()
options.headless = True
options.add_argument('--remote-debugging-port=61625')
options.add_argument('--no-sandbox')
webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=options)
print(driver)
The output is
<selenium.webdriver.chrome.webdriver.WebDriver (session="70ca99a865d0eb7b93a95f530ef1401b")>

Driver is downloading and Second time the new errror appears

Good Morning Everyone.
Below the automation code in selenium with python.
It was working previously in past OS- ubuntu.
I have installed the new Mint Linux, installed the pycharm and downloaded the code from Github.
First time it is downloading the chrome driver and it gives the error.
Second time it is giving this error.
code:-
import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
s = Service(ChromeDriverManager().install())
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
#browser = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=chrome_options, service_args=['--verbose', '--log-path=/tmp/chromedriver.log'])
browser = webdriver.Chrome(service=s, options=chrome_options)
#browser = webdriver.Chrome(options=Options)
browser.implicitly_wait(5)
"""
Going to use drag and drop
get the details from the mouse hover details
"""
browser.get("https://www.rahulshettyacademy.com/AutomationPractice")
browser.maximize_window()
print(browser.title)
#//a[normalize-space()='Top']
#//button[#id='mousehover']
action = ActionChains(browser)
Error Message:-
/home/halovivek/PycharmProjects/yearcoding/venv/bin/python /home/halovivek/PycharmProjects/yearcoding/22092022_selenium1.py
Traceback (most recent call last):
File "/home/halovivek/PycharmProjects/yearcoding/22092022_selenium1.py", line 16, in <module>
browser = webdriver.Chrome(service=s, options=chrome_options)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/halovivek/PycharmProjects/yearcoding/venv/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Stacktrace:
#0 0x555ab50bc693 <unknown>
#1 0x555ab4eb5b0a <unknown>
#2 0x555ab4ed846e <unknown>
#3 0x555ab4ed61f4 <unknown>
#4 0x555ab4f11953 <unknown>
#5 0x555ab4f0b743 <unknown>
#6 0x555ab4ee1533 <unknown>
#7 0x555ab4ee2715 <unknown>
#8 0x555ab510c7bd <unknown>
#9 0x555ab510fbf9 <unknown>
#10 0x555ab50f1f2e <unknown>
#11 0x555ab51109b3 <unknown>
#12 0x555ab50e5e4f <unknown>
#13 0x555ab512fea8 <unknown>
#14 0x555ab5130052 <unknown>
#15 0x555ab514a71f <unknown>
#16 0x7f2b51a711da <unknown>
#17 0x7f2b51af9d84 <unknown>
Process finished with exit code 1
I dont know why this suddenly happening. I need solution to continue my learning and writing the code. Thank you.
Good day Ahead.
Since I could not able to find the solution.
I just reinstalled the whole operating system.
I installed Ubuntu again from Linux Mint.
Now the code is working fine.
thank you

Could Not Open Site In Firefox Through Python

I tried to open a site in firefox through selenium python, when i run the code it opens firefox after that nothing happens ,
WATCH THIS --> HOW TO USE FIREFOX IN PYTHON & HOW TO SET VALUES IN DROP-DOWN LISTS?
here is the error
bash-3.1$ C:/Users/user/AppData/Local/Programs/Python/Python35-32/python.exe d:/PYTHONS/EXTRACT-NEWS/FFD
RIVER.py
Traceback (most recent call last):
File "d:/PYTHONS/EXTRACT-NEWS/FFDRIVER.py", line 23, in <module>
executable_path=r"D:\\PYTHONS\\DRIVERS\\geckodriver.exe")
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 174, in __init__
keep_alive=True)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "c:\Users\user\AppData\Local\Programs\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: newSession
WHEN I RUN THE CODE I GOT THIS ERR
HOW TO USE FF IN PYTHON?
THX IN ADVANCE
# Import Libraries
import os
import sys
import time
from selenium import webdriver
import selenium.webdriver.firefox.options
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
# Configure Firefox Options
profile = webdriver.Firefox(
executable_path=r"D:\\PYTHONS\\DRIVERS\\geckodriver.exe")
# 0 means to download to the desktop, 1 means to download to the default "Downloads" directory, 2 means to use the directory
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", download_path)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference(
"browser.helperApps.neverAsk.saveToDisk", "application/x-gzip/text/csv")
os.system("cls")
# firefox_profile=profile
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('https://www.google.com')
print(driver.title)
# driver.quit()
[1]: https://i.stack.imgur.com/T3Bf8.png
To set preference you have to use FirefoxProfile() instead of Firefox()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", '.')
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip/text/csv")
driver = webdriver.Firefox(firefox_profile=profile, executable_path="D:\\PYTHONS\\DRIVERS\\geckodriver.exe")
driver.get('https://www.google.com')
print(driver.title)
BTW: and don't run webdriver.Firefox() two times beacuse Selenium doesn't know how to run two browsers at the same time - and this gave you error message.

Headless Chrome Navigate to Page, click to linked page, then printToPDF

I have to print all HTML pages linked to from a product information page:
http://prod.adv-bio.com/ProductDetail.aspx?ProdNo=1197
I have set up a test script to see if I could do this for just one of the HTML files. I used PyChromeDevTools and Selenium, hoping I could use the printToPDF function in DevTools while using Selenium to click the links I need to click.
Here is the code I have so far:
import requests
import time
import re
import websocket
import PyChromeDevTools
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--remote-debugging-port=9222')
chrome_options.add_argument('--window-size=1200x600')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome('C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python36- 32\\selenium\\webdriver\\chromedriver_win32\\chromedriver.exe', chrome_options = chrome_options)
driver.get("http://prod.adv-bio.com/ProductDetail.aspx?ProdNo=1197")
browser = PyChromeDevTools.ChromeInterface()
browser.Network.enable()
browser.Page.enable()
driver.implicitly_wait(20)
driver.get("http://prod.adv-bio.com/ProductDetail.aspx?ProdNo=1197")
time.sleep(3)
url = driver.find_element_by_partial_link_text("Continuing")
time.sleep(3)
ActionChains(driver).click(url).perform()
time.sleep(3)
Page.printToPDF()
time.sleep(5)
and I am getting this error
Traceback (most recent call last):
File "C:\Users\me\SOtestfile.py", line 29, in <module>
driver = webdriver.Chrome('C:\\Python27\\Lib\\site-
packages\\chromedriver_win32\\chromedriver.exe', chrome_options =
chromeOptions, desired_capabilities=capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 98, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: chrome not reachable
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7601 SP1 x86_64)
I have updated chromedriver to 2.31 and have chrome version 60, should I be using canary? I appreciate any help on this.
from selenium.webdriver.common.desired_capabilities import
DesiredCapabilities
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("headless")
chromeOptions.add_argument("window-size=1366,768")
capabilities = DesiredCapabilities.CHROME.copy()
capabilities["browserName"] = "chrome"
driver = webdriver.Chrome(chrome_options=chromeOptions,
desired_capabilities=capabilities)
Worked here!! (Chrome 60 + Chromedriver 2.31) Hope this helps!!

Categories