2016-08-19 62 views
1

我想学习如何在C#创建Selenium测试,下面就hereSelenium测试:不允许的方法错误

设置功能说明:

[SetUp] 
    public void SetupTest() { 
     selenium = selenium = new DefaultSelenium("TestServer", 4444, "*iexplore", BaseUrl); 
     selenium.Start(); 
     verificationErrors = new StringBuilder(); 
    } 

每当我跑我的测试,硒。开始();抛出以下异常:

System.Net.WebException:远程服务器返回错误:(405)方法不允许。

结果堆栈跟踪:

at System.Net.HttpWebRequest.GetResponse() 
    at Selenium.HttpCommandProcessor.DoCommand(String command, String[] args) 
    at Selenium.HttpCommandProcessor.Start() 
    at Selenium.DefaultSelenium.Start() 
    at SeleniumTests.IMPORT.SetupTest() 

硒服务器(版本3.0.0.beta)在远程服务器上运行,我已经打开端口4444

+0

您是否能够通过输入您提供给Selenium的相同url来在浏览器中查看页面?你是否也使用http或https? – neo

回答

2

你应该使用Selenium网络驱动器,而不是Selenium RC。硒RC是旧的。我使用C#使用Selenium Web Driver的方式如下。

IWebDriver driver = new InternetExplorerDriver(); 
driver.Navigate().GoToUrl("https://www.example.com");