1
votes

I can drive a headless browser using selenium and Chrome Canary. But I can't get it to work using Splinter.

Thanks in advance.

Here's what works.

import os  
from selenium import webdriver  
from selenium.webdriver.common.keys import Keys  
from selenium.webdriver.chrome.options import Options

chrome_options = Options()  
chrome_options.add_argument("--headless")  
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'   
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',   chrome_options=chrome_options)

Here's what doesn't work:

from splinter import Browser
executable_path = {'executable_path':'/Applications/Google Chrome Canary/Contents/MacOS/Google Chrome Canary'}
B=Browser('chrome',**executable_path)

Incidentally Splinter DOES work with phantomjs

executable_path = {'executable_path':'/Applications/phantomjs/bin/phantomjs'}
 B=Browser('phantomjs',**executable_path )

The error message is

WebDriverException: Message: 'Google Chrome Canary' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Here's the path, as perceived by os.os.environ['PATH']

/Users/jonschull-MBPR/miniconda2/bin:/Applications/Google Chrome Canary/Contents/MacOS/Google Chrome Canary:/Users/jonschull-MBPR/miniconda2/bin:/Users/jonschull-MBPR/anaconda/bin:/Users/jonschull-MBPR/Downloads/google-cloud-sdk/bin:/opt/local/bin:/opt/local/sbin:/Users/jonschull-MBPR/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/chromedrive:/opt/X11/bin:/usr/local/mongodb/bin

And by the way, I've tried escaping "Google\ Chrome\ Canary "

1
Welcome to Stack Overflow, please add your solution as an answer instead of editing your post. - Bhargav Rao

1 Answers

0
votes

Well, according to issue in splinter's git you just need to upgrade to splinter 0.7.6+.