from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = 'C:\Users\mpmccurdy\Desktop\Google Chrome Canary.lnk'
options.add_argument('headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.python.org")
Asked
Active
Viewed 1,943 times
1

undetected Selenium
- 183,867
- 41
- 278
- 352

Marshall McCurdy
- 55
- 2
- 10
-
when i run this script, chrome browser stills pulls up – Marshall McCurdy May 30 '18 at 14:13
-
1What are the chrome and the chrome driver versions that you are using? Try with `options.add_argument('--headless')` if your chrome version > 59 – GPT14 May 30 '18 at 14:24
-
i have version 67.0 – Marshall McCurdy May 30 '18 at 14:38
2 Answers
0
chrome_options = Options()
chrome_options.add_argument("--headless")
path = os.getcwd() +'\\chromedriver.exe' #needs to be in your current working directory
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=path)

It_is_Chris
- 13,504
- 2
- 23
- 41
-
1While this answer is probably correct and useful, it is preferred if you include some explanation along with it to explain how it helps to solve the problem. This becomes especially useful in the future, if there is a change (possibly unrelated) that causes it to stop working and users need to understand how it once worked. – Erty Seidohl May 30 '18 at 15:26
-
0
If you are using Chrome Canary as a basic Requirement the server still expects you to have Chrome installed in the default location as per the underlying OS architecture as follows:
You can also override the default Chrome Binary Location following the documentation Using a Chrome executable in a non-standard location as follows:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
options.add_argument('--headless')
options.add_argument('window-size=1200x600')
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get("https://www.python.org")

undetected Selenium
- 183,867
- 41
- 278
- 352