2011-12-29 231 views
16

使用​​運行Selenium 2 RemoteWebDriver服務器。Selenium WebDriver HTTP錯誤:403禁止代理RequestURI =/session

我總是得到錯誤:

HTTP ERROR: 403 
Forbidden for Proxy 
RequestURI=/session 
連接到它時使用Python webdriver的客戶

import selenium.webdriver as webdriver 
webdriver.Remote('http://localhost:4444', {}) 

或任何其他各種RemoteWebDriver客戶,我能找到。

回答

37

解決辦法很簡單:使用路徑/wd/hub

import selenium.webdriver as webdriver 
webdriver.Remote('http://localhost:4444/wd/hub', {}) 
+1

將此標記爲答案嗎?我認爲你有一個徽章給你。 http://stackoverflow.com/help/badges/14/self-learner – 2014-11-02 12:01:09

+0

是的,你應該標記你的答案,爲其他用戶。 – 2016-09-17 04:49:56

+0

你的回答太簡單了。我不明白。我應該在哪裏編寫代碼? – 2017-12-11 19:37:35

3

不要完全相同問題的解決方案,但對人收到此錯誤:

HTTP ERROR: 403 

Forbidden for Proxy 
RequestURI=/ 

Powered by Jetty:// 

這出現錯誤,例如如果硒的多個實例在運行,所以你需要關閉它通過瀏覽網址:

http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer 

如果另一個實例正在運行,應該出現okok

1

你有這勢必相同的端口另一個進程即4444.

Selenium Grid默認使用端口:4444。

您或者需要終止綁定到端口4444的進程,否則您需要爲集線器使用另一個端口(以下使用5555)。

使用下面的命令提示符:

Java的罐子硒的服務器獨立-2.15.0.jar -role樞紐-port 5555