2012-07-10 1 views
0

Windows 7에서 python으로 Selenium webdriver와 함께 Chrome 브라우저를 열려고하지만 중단됩니다.셀레늄은 win7에서 python으로 크롬 브라우저를 열 수 없습니까?

`

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") 

`

당신이 날 도와 줘요 수 : 아래는 내가 사용하는 코드는? 고맙습니다!

+0

거기에 디버그 코드가 있습니다. 그게 무슨 전화 야? 그리고 당신은 어떤 오류 출력을 받고 있습니까? –

+0

오류가 없습니다. 행 아웃하기 전에 출력 마지막 줄이 2 개 있습니다. 바이너리 loc service url http : // localhost : 64960 –

+0

가끔 끝에 도달하지만 브라우저가 열리지 않습니다. –

답변

0

제거 :

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" 

지금 무슨 일이 일어 나는지 확인하십시오. 크롬을 인스턴스화 할 때 chromedriver에 대한 경로를 설정하고 나에게 잘 작동합니다. 또한 Python27에서 크롬 드라이버를 실행하는 데 문제가있을 수 있습니다.

+0

응답 해 주셔서 감사합니다. 내가 포함 된 및 '브라우저 = webdriver.Chrome ("C : \\ chromedriver.exe")'시도했지만 아무 일도 발생하지 않습니다. 작업 관리자에서 chromeriver는 열리지 만 크롬 프로세스는 없음을 알 수 있습니다. Win7에서 실행 했습니까? –

+0

또한 64 비트 플랫폼에서 win7을 지정해야합니다. chromeriver가 Chrome 브라우저를 여는 데 문제가 될 수 있습니까? –

0

몇 가지 사항을 변경했습니다. 내 컴퓨터에 파일이 없기 때문에 ChromeOpt를 꺼내서 작동합니다. chromelever를 PATH에 추가했는지 확인해야합니다.

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 
import os 



chromedriver = "C:\Users\USER\AppData\Local\Google\Chrome\Application\chromedriver.exe" 
os.environ["webdriver.chrome.driver"] = chromedriver 

print "after binary loc" 
browser = webdriver.Chrome(chromedriver) 
print "after browser", browser 
print dir(browser) 
browser.get("http://www.google.com") 
관련 문제