我尝试过使用google,但是有很多不同的方法可以使用Selenium。我正在使用:-Windows 2003 Server-Visual Studio 2008-通过Firefox安装的Selenium IDE-将NUnit 2.5复制到C:\-将硒RC复制到C:\
使用系统; 使用System.Text; 使用System.Text.RegularExpressions; 使用System.Threading; 使用NUnit.Framework; 使用硒 命名空间SeleniumTest { [TestFixture] 公共类NewTest { 私有ISelenium硒; 私人StringBuilder验证错误; [SetUp] public void SetupTest() { selenium = new DefaultSelenium(“ localhost”,4444,“ * iexplore”,“ http:// localhost:4444”); selenium.Start(); VerificationErrors = new StringBuilder(); } [TearDown] 公共无效的TeardownTest() { 尝试 { selenium.Stop(); } catch(Exception) { //如果无法关闭浏览器,则忽略错误 } Assert.AreEqual(“”,“”); } [测试] public void TheNewTest() { selenium.Open(“ /google.com”); } } }
SeleniumTest.NewTest.TheNewTest:Selenium.SeleniumException:XHR错误:URL = http:// localhost:4444 / google.com Response_Code = 403 Error_Message = Forbidden + for + Proxy
由于将baseURL设置为Selenium RC的baseURL,因此收到了Forbidden错误。您需要将其设置为http://www.google.com,然后在测试中
[Test]
public void TheNewTest()
{
selenium.Open( "/" );
}
或者您需要将测试更改为
[Test]
public void TheNewTest()
{
selenium.Open( "http://www.google.com" );
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句