【发布时间】:2013-03-07 13:44:43
【问题描述】:
我正在使用 python ana selenium 来自动化某些过程,但无法将 selenium 附加到默认的 chrome 配置文件 我试过了,
capability = webdriver.DesiredCapabilities.CHROME
self.driver = webdriver.Remote('http://127.0.0.1:9515/wd/hib',capability)
当然,我开始了,chromedriver先,也试过了,
import time
from selenium import webdriver
import selenium.webdriver.chrome.service as service
service = service.Service('./chromedriver')
service.start()
capabilities = {'chrome.binary': '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'}
driver = webdriver.Remote(service.service_url, capabilities)
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
driver.quit()
这会导致 selenium.common.exceptions.WebDriverException: Message: u'Could not find Chrome binary at:
也试过了,
self.driver = webdriver.Chrome("./chromedriver")
这可行,但不是默认配置文件,并且还想知道如何使用它打开新窗口或新标签?
谢谢。
【问题讨论】:
-
Chrome 二进制文件是否存在于:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome?这就是你说的! -
感谢您的回复,据此,code.google.com/p/selenium/wiki/ChromeDriver 是的。