我们可以与IIS中运行,而不是Visual Studio开发服务器webdriver的硒测试的情况下, [英] Can we run Selenium WebDriver Test case with IIS, instead of Visual Studio Development server

查看:160
本文介绍了我们可以与IIS中运行,而不是Visual Studio开发服务器webdriver的硒测试的情况下,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与硒2的webdriver工作。取而代之的UnitTest项目,我开始从因为以下原因网站:

I am working with Selenium 2 WebDriver. Instead of UnitTest project, i initiate it from website because of following reasons:


  1. 应每隔24小时自动运行。我一直在使用的System.Threading写了一些调度code。

  2. 提供一些UI客户,当他们需要的中等运行它。

  3. 在每次运行一个邮件发送格式是测试结果的一部分。

我的目标网站: http://www.vroomvroomvroom.com.au

我创建了具有所有硒code的Class。我打电话使用的System.Threading在Default.aspx的页面加载的类。

I have created a Class which has all the Selenium Code. I call that Class using System.Threading upon page load of default.aspx.

它正常工作时,我的Default.aspx从Visual Studio由pressing F5或Ctrl + F5键即与Visual Studio开发服务器运行例如的http://本地主机:3251 / Default.aspx的

It works fine when i run default.aspx from visual studio by pressing F5 OR Ctrl+F5 i.e. with Visual Studio development server e.g. http://localhost:3251/default.aspx.

但是,当我试图直接从IIS中运行它,使用默认端口(80)如 HTTP://localhost/seleniumTest/default.aspx ,那么它失败下列意见/错误:

But, when i try to run it directly from IIS, with default port (80) e.g. http://localhost/seleniumTest/default.aspx, then it fails with following observation/error:


  1. 它运行硒code到延长,但不显示broswer。

  2. 这与从服务器无响应的URL为http一些步骤失败后://本地主机:7094 /集线器/会话/ 4bbe4b0c-aeee-4fa3-8bc0-aae47c6869af /元素

  1. It runs the Selenium code to an extend, but doesn't show the broswer.
  2. It fails after some steps with No response from server for url http://localhost:7094/hub/session/4bbe4b0c-aeee-4fa3-8bc0-aae47c6869af/element

这可能正是我想要的目的。

It is possible what i am trying to achieve.

FYI:让我知道,如果需要进一步的细节。

FYI: Let me know if further details are required.

推荐答案

我设法找到解决办法喽。

I have managed to find the solution myself.

基本上,RemoteWebDriver有可能被用来代替FirefoxDriver。
操作步骤:

Basically, RemoteWebDriver has to be used instead of FirefoxDriver. Steps:


  1. 更改FirefoxDriver的初始化RemoteWebDriver为:

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。下载硒独立服务器,并通过使用命令提示符开始吧〜

2. Download Selenium Standalone server and initiate it via command prompt using ~

java -jar E:\Software\selenium-server-standalone-2.24.1.jar -interactive -port 4545

该方法有2好处:


  1. 一个可以使用本地IIS运行测试。

  2. 测试可以远程运行。请参阅硒RC文件。人们可以看到截图远程使用

  1. One could use the local IIS for running the test.
  2. Test could be run remotely. Refer Selenium RC documentation. One could see the screenshots remotely using

REMOTE_IP:4545 / WD /集线器/静态/资源/ hub.html

REMOTE_IP:4545/wd/hub/static/resource/hub.html

我想修改在它使用hub.html和client.js文件code,以提供更好的远程感觉。

I am thinking to modify the code of hub.html and client.js file used within it to provide a better Remote feel.

我希望这能够成为别人有用。

I hope this can be useful for others as well.

FYI:


  1. IP地址REMOTE_IP可以改变任何实时IP地址或本地主机。而发起页面请求使用上述端口。

  2. 独立服务器的启动/停止code可以安装在测试里面,所以它自动启动/通过批处理文件停止。

  3. 将不关闭命令提示符下保持服务器运行。

这篇关于我们可以与IIS中运行,而不是Visual Studio开发服务器webdriver的硒测试的情况下,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆