2010-03-04 111 views
0

我正在使用Selenium進行一些Web測試。我的代碼如下所示:遠程服務器返回錯誤:(401)使用任何站點時未經授權

 selenium = new DefaultSelenium("localhost", 80, "*firefox", "http://www.google.co.uk/firefox?client=firefox-a&rls=org.mozilla:en-GB:official"); ; 

     selenium.Start(); 

     selenium.GetText("/html/body[@id='mozilla-com']/div[1]/div[2]/div[2]/h2/span"); 

不過,我得到一個錯誤,說明:

遠程服務器返回錯誤:(401)未經授權。

任何人有任何想法爲什麼?

感謝

回答

1

看起來你是在端口80上運行在開發機器上的IIS就會有衝突。

當你開始用硒java -jar Selenium-Server-Standalone.jar所以如果您的測試更新,以

selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.co.uk/firefox?client=firefox-a&rls=org.mozilla:en-GB:official"); ; 

selenium.Start(); 

selenium.GetText("/html/body[@id='mozilla-com']/div[1]/div[2]/div[2]/h2/span"); 

應該做你想要什麼它在端口4444默認情況下啓動。我在我的網站上有一個Selenium C#教程,http://www.theautomatedtester.co.uk/seleniumtraining/selenium_csharp_nunit.htm應該可以幫助你完成整個過程。如果你被卡住了,我的網站上有很多教程

相關問題