Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jenkins启动Selenium测试用例_Jenkins_Webdriver_Selenium Webdriver_Remotewebdriver - Fatal编程技术网

使用jenkins启动Selenium测试用例

使用jenkins启动Selenium测试用例,jenkins,webdriver,selenium-webdriver,remotewebdriver,Jenkins,Webdriver,Selenium Webdriver,Remotewebdriver,我已经使用selenium webdriver准备了一个测试用例,我使用MSTEST在本地运行,它运行良好,现在我想将我的测试用例转移到JENKINS,当我从JENKINS运行时,它说开始执行。。。它超过了15个MNT,但状态仍然相同,所以我必须手动停止它 以下是我的控制台输出: Started by user anonymous Started by user anonymous Building in workspace D:\Jenkins\jobs\Selenium_Script\wor

我已经使用selenium webdriver准备了一个测试用例,我使用MSTEST在本地运行,它运行良好,现在我想将我的测试用例转移到JENKINS,当我从JENKINS运行时,它说开始执行。。。它超过了15个MNT,但状态仍然相同,所以我必须手动停止它

以下是我的控制台输出:

Started by user anonymous
Started by user anonymous
Building in workspace D:\Jenkins\jobs\Selenium_Script\workspace
[workspace] $ cmd /c call C:\Users\XXXXXXX\AppData\Local\Temp\hudson4765437871038045571.bat

D:\Jenkins\jobs\SelScript\workspace>call "D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest" /testcontainer:D:\Sel\EmployeeTest\test.emp.admin.dll 
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.

Loading D:\Sel\EmployeeTest\test.emp.admin.dll...
Starting execution...

Build was aborted
Finished: ABORTED
我想在Jenkins上执行测试用例并检查执行结果

这是我的代码,以防万一

这是我用来实例化我的驱动程序的,我必须使用RemoteDriver吗


您可以在Jenkins的构建部分运行Selenium脚本

单击AddBuildStep并选择ExecuteShell,在那里您可以像在Linux环境中键入命令一样直接运行命令

所有这些都假设您正在运行Linux环境中的Jenkins

@我必须使用RemoteDriver吗? 取决于是否安装了xvfb以无头模式运行测试? 如果不是,那么是的,您可以重定向测试以在windows/mac计算机上远程运行

更新

如果您有windows计算机,则不需要xvfb。所以忘了那件事吧

Shell脚本默认为sh,但这对于构建项目是可配置的。脚本将以工作区作为当前目录运行。键入shell脚本的内容。如果您的shell脚本没有像这样的标题行/bin/sh-,则将使用shell配置的系统范围,但您也可以使用标题行以另一种语言编写脚本,如/bin/perl或控制shell使用的选项。 默认情况下,将使用-ex选项调用shell。因此,所有命令在执行之前都会打印出来,如果任何命令退出时带有非零退出代码,则构建将被视为失败。再次添加/bin/。。。行来更改此行为

作为一种最佳实践,尽量不要在这里放一个长的shell脚本。相反,考虑在SCM中添加shell脚本,并简单地通过BASH-EXMyScript .SH或类似的方法从詹金斯调用shell脚本,这样您就可以跟踪shell脚本中的更改。 范例-

您可以像这样运行ruby命令

ruby testscripts.rb
或者像这样的shell脚本

./testscripts.sh

詹金斯非常容易。只要这样做:

  1.  Allow Jenkins to check-out your code into the Jenkins workspace.
  2.  Navigate to that workspace on your Windows computer and manually run
      the tests by executing the script that starts them.

这样做,詹金斯暂时不在考虑范围之内,因此不再是你问题的原因。然后,你可以关注真正的问题是什么。解决问题后,请检查对源代码repo的更改,然后再次运行Jenkins构建并尝试再次手动运行。如果这也行的话,那么最后,您可以在Jenkins中设置生成任务来运行测试。

我使用的是windows环境,并假设我将像这样执行shell D:\Jenkins\jobs\SelScript\workspace>调用D:\Program Files x86\Microsoft Visual Studio 10.0\Common7\IDE\mstest/testcontainer:D:\Sel\EmployeeTest\test.emp.admin.dlw xvfb/headless是什么?对我来说,我是新手it@Amey:我通过testng.xml在Windows中运行selenium webdriver脚本。我的Jenkins服务器在Linux中运行。如何调用testng.xml?
  1.  Allow Jenkins to check-out your code into the Jenkins workspace.
  2.  Navigate to that workspace on your Windows computer and manually run
      the tests by executing the script that starts them.