[英]Passing set of file Paths from the command line to on “npm run test”?
[英]I want to run Selenium test case file from command line
然后我用Firefox扩展“Selenium IDE”保存了一个测试用例。
现在我想使用命令行来运行这个导出的html文件。
我尝试遵循这个如何启动-se -ium-ide-from-the-command-line-with-a-specific-test-case但它不起作用。
请帮我。
您将需要Selenium RC,您可以从中获得:
http://seleniumhq.org/download/
和Java 1.5或更高版本( 在这里下载Java )
1)安装Java
2)打开Selenium RC包装。
3)打开cmd.exe窗口并转到包含Selenium Server的目录( selenium-remote-control-1.0.1\\selenium-server-1.0.1
)
4)运行以下命令:
java -jar selenium-server.jar -htmlSuite "*firefox" "http://10.8.100.106" "C:\mytestsuite\mytestsuite.html" "C:\mytestsuite\results.html"
这应该在Firefox中运行您的测试套件并将结果写入html文件。 显然你需要将"http://10.8.100.106"
参数更改为你自己的服务器(这可能只是localhost / 127.0.0.1
)
可以使用Selenese Runner运行单个测试用例。 您可以指定单个测试用例文件或测试套件作为要运行的单元。
我们应该使用以下命令执行SeleniumRC;
java -jar filename.jar
例如:
java -jar program1.jar
program1包括以下内容:
program1.class
文件 Server.jar
和Selenium Java client.jar文件 此方法适用于SeleniumRC执行。 我们可以使用File-> Export直接从eclipse创建program1.jar
文件。
这篇文章向您解释了如何在Java中运行Selenium RC应用程序的分步过程。
我之前需要这样做,并使用以下内容:
最常见的是,我们会在尝试从cmd运行时遇到构建路径错误。
为了能够在Chrome浏览器中运行,您可以使用* chrome选项代替* firefox,如下所示
java -jar selenium-server.jar -htmlSuite "*chrome" "http://localhost" "C:\testsuite\testsuite.html" "C:\testsuite\results.html"
其他浏览器列表包括:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3
*safariproxy
*googlechrome
*konqueror
*firefox2
*safari
*piiexplore
*firefoxchrome
*opera
*iehta
*custom
在会话上null
如果你想从命令提示符运行它,你可以考虑在python中编写你的selenium测试。 如果你在Windows上,请确保安装了python。 Mac默认会有python。
1)从CMD运行
java -cp "C:\ProjectX\Mortgage\bin;C:\Selenium_latest\selenium2.49.1\*;C:\Selenium_latest\selenium-2.49.1\libs\*" org.testng.TestNG C:\ProjectX\Mortgage\testng.xml
在C:\\ ProjectX \\ Mortgage中运行以上命令
2)创建批处理文件名runner.bat
SET projectLocation=C:\ProjectX\Mortgage
CD %projectLocation%
SET classpath=%projectLocation%\bin;C:\Selenium_latest\selenium-2.49.1\*;C:\Selenium_latest\selenium-2.49.1\libs\*
java org.testng.TestNG %projectLocation%\testng.xml
PAUSE
3)双击运行批处理文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.