3

我試着設置了selenium的遠程webdriver。在我的遠程機器上,selenium服務器正在運行,並接收到我從本地打出的請求。但在我的地方,爲什麼會出現這些錯誤?不知道selenium遠程webdriver錯誤

from selenium import webdriver 
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver 
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 
from selenium.webdriver import ChromeOptions 
import os 

chromedriver = '/Users/guru/Downloads/chromedriver' 
os.environ["webdriver.chrome.driver"] = chromedriver 
driver = RemoteWebDriver(
    command_executor='http://ec2-XXX-XXX-XXX-XXX.compute.com:4444/wd/hub', 
    desired_capabilities=DesiredCapabilities.CHROME) 

driver.get('http://voot.com') 

爲什麼會出現這個錯誤

Traceback (most recent call last): 
    File "/Users/guru/python_projects/implement/a/format.py", line 11, in <module> 
    desired_capabilities=DesiredCapabilities.CHROME) 
    File "/Users/guru/python_projects/implement/a/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__ 
    self.start_session(desired_capabilities, browser_profile) 
    File "/Users/guru/python_projects/implement/a/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session 
    response = self.execute(Command.NEW_SESSION, capabilities) 
    File "/Users/guru/python_projects/implement/a/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute 
    self.error_handler.check_response(response) 
    File "/Users/guru/python_projects/implement/a/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response 
    raise exception_class(message, screen, stacktrace) 
selenium.common.exceptions.WebDriverException: Message: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html 
Stacktrace: 
    at com.google.common.base.Preconditions.checkState (Preconditions.java:199) 
    at org.openqa.selenium.remote.service.DriverService.findExecutable (DriverService.java:109) 
    at org.openqa.selenium.chrome.ChromeDriverService.access$0 (ChromeDriverService.java:1) 
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable (ChromeDriverService.java:137) 
    at org.openqa.selenium.remote.service.DriverService$Builder.build (DriverService.java:296) 
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService (ChromeDriverService.java:88) 
    at org.openqa.selenium.chrome.ChromeDriver.<init> (ChromeDriver.java:138) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (None:-2) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (None:-1) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (None:-1) 
    at java.lang.reflect.Constructor.newInstance (None:-1) 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor (DefaultDriverProvider.java:103) 
    at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance (DefaultDriverProvider.java:97) 
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:60) 
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222) 
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:1) 
    at java.util.concurrent.FutureTask.run (None:-1) 
    at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1) 
    at java.lang.Thread.run (None:-1) 

Process finished with exit code 1 

回答

0

設置遠程機器上要運行的測試下面的東西。

設置使用以下命令chromedriver父文件夾的路徑系統PATH:

export PATH = /Users/prashant/Downloads/:$PATH 
echo $PATH 

你應該設置輕拍至.exe文件如下:

chromedriver = '/Users/guru/Downloads/chromedriver/chromedriver.exe' 
os.environ["webdriver.chrome.driver"] = chromedriver 
+0

我在OSX,什麼應該延長我用 ? 它不應該是.exe – Guru

+0

btw文件信息說,'chromedriver'是驅動程序的名稱,包括擴展名 – Guru

+0

你可以編輯你的答案嗎?它不工作 – Guru

相關問題