我试过谷歌,但有很多不同的方式来使用硒。我使用的是: - Windows 2003 Server的 - Visual Studio 2008中 - 通过Firefox浏览正常 安装硒IDE - NUnit的2.5被复制到C:\ - 硒RC被复制到C:\如何设置Selenium使用C#使用Visual Studio .NET?
- 首先我使用C#创建了一个库项目。
- 这我的课:
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using Selenium; namespace SeleniumTest { [TestFixture] public class NewTest { private ISelenium selenium; private StringBuilder verificationErrors; [SetUp] public void SetupTest() { selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost:4444"); selenium.Start(); verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { selenium.Stop(); } catch(Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", ""); } [Test] public void TheNewTest() { selenium.Open("/google.com"); } } }
- 下从C添加的所有引用:\硒RC \硒DOTNET客户端驱动器-1.0.1
- 编译图书馆计划,成功了。没有错误。
- 运行NUnit.exe,现在的错误:(
SeleniumTest.NewTest.TheNewTest: Selenium.SeleniumException : XHR ERROR: URL = http://localhost:4444/google.com Response_Code = 403 Error_Message = Forbidden+for+Proxy
您好, 我在将它更改为
SeleniumTest.NewTest.TheNeTest: Sel enium.SeleniumException:错误:命令执行失败。请在http://clearspace.openqa.org上搜索论坛,查看日志窗口中的错误详情。错误消息是:访问被拒绝。 – Chan 2010-07-28 17:27:04将baseURL设置为http://www.google.com,然后打开(“/”); – AutomatedTester 2010-07-28 17:58:55
我尝试了很多不同的方法。即使我创建了一个控制台应用程序而不是类库来测试它。但它似乎冻结而不是运行http://google.com。出现了Selenium Remote Control v.2。这是用Firefox打开的链接:http:// localhost:4444/selenium-server/core/Blank.html?start = true 你能告诉我我错过了什么吗? 谢谢 这是博客: – Chan 2010-07-28 19:19:43