我正在使用Selenium 2 WebDriver。而不是UnitTest项目,我从网站发起它,原因如下:
我的目标网站是:http://www.vroomvroomvroom.com.au
我创建了一个包含所有Selenium代码的类。我在default.aspx的页面加载时使用System.Threading调用该类。
当我通过按F5或Ctrl + F5从Visual Studio运行default.aspx时工作正常,即使用Visual Studio开发服务器,例如http://localhost:3251/default.aspx
。
但是,当我尝试直接从IIS运行它时,使用默认端口(80),例如http://localhost/seleniumTest/default.aspx
,然后因以下观察/错误而失败:
No response from server for url http://localhost:7094/hub/session/4bbe4b0c-aeee-4fa3-8bc0-aae47c6869af/element
我想要实现的目标是可能的。
仅供参考:如果需要进一步的详细信息,请与我们联系。
答案 0 :(得分:8)
我自己设法找到了解决方案。
基本上,必须使用RemoteWebDriver而不是FirefoxDriver。 步骤进行:
从
改变IWebDriver driver = new FirefoxDriver();
要
DesiredCapabilities capability = DesiredCapabilities.Firefox();
Uri url = new Uri("http://REMOTE_IP:4545/wd/hub");
IWebDriver driver = new RemoteWebDriver(url, capability);
2。下载Selenium Standalone服务器并使用〜
通过命令提示符启动它java -jar E:\Software\selenium-server-standalone-2.24.1.jar -interactive -port 4545
这种方法有两个好处:
可以远程运行测试。请参阅Selenium RC文档。可以使用
远程查看截图REMOTE_IP:4545 / WD /集线器/静态/资源/ hub.html
我正在考虑修改其中使用的hub.html和client.js文件的代码,以提供更好的远程感觉。
我希望这对其他人也有用。
仅供参考: