我想在Windows 7上使用python中的selenium webdriver打開chrome瀏覽器,但它掛起。下面是我使用的代碼:硒在python中無法在win7上打開chrome瀏覽器?
`
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.proxy import *
import time
from pprint import pprint
chromeOps = webdriver.ChromeOptions()
print "after chrome opts", chromeOps
print dir(chromeOps)
pprint(chromeOps)
chromeOps.binary_location = "C:\\Users\\cvoicu\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
print "after binary loc"
browser = webdriver.Chrome("C:\\Python27\\chromedriver.exe", chrome_options=chromeOps)
print "after browser", browser
print dir(browser)
browser.get("http://www.google.com")
`
你能幫助我嗎?謝謝!
我看到你有一些調試代碼在那裏。它掛着什麼電話?你是否收到任何錯誤輸出? – 2012-07-10 13:38:33
這裏沒有任何錯誤。這裏有兩條最後一行的輸出前掛: 二進制loc後 服務網址http:// localhost:64960 – 2012-07-10 13:54:29
有時達到最後,但它不打開瀏覽器。 – 2012-07-10 13:57:39