2017-08-05 2 views
1

Je peux conduire un navigateur sans tête en utilisant le sélénium et Chrome Canary. Mais je n'arrive pas à l'utiliser avec Splinter.Splenter sans sélénium sans tête avec Chrome Canary (python)

Merci d'avance.

Voici ce qui fonctionne.

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) 

est ici ce qui ne fonctionne pas:

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

Soit dit en passant Splinter fonctionne avec PhantomJS

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

Le message d'erreur est

WebDriverException: Message: Google L'exécutable Chrome Canary doit être en CHEMIN. S'il vous plaît voir https://sites.google.com/a/chromium.org/chromedriver/home

Voici le chemin, tel qu'il est perçu par 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 

Et par ailleurs, je l'ai essayé échapper "Google \ Chrome \ Canary"

+0

Bienvenue dans Stack Overflow, veuillez ajouter votre solution en guise de réponse au lieu de modifier votre message. –

Répondre