简体   繁体   English

通过 jenkins 在 linux box 上执行 Selenium 测试

[英]Selenium test execution via jenkins on linux box

How to run selenium webdriver scripts via jenkins on linux machine and publish the test results in Jenkins?如何在 linux 机器上通过 jenkins 运行 selenium webdriver 脚本并在 Jenkins 中发布测试结果?

I am using Jenkins as my Continuous integration tool.我使用 Jenkins 作为我的持续集成工具。 Jenkins is running in linux machine. Jenkins 在 linux 机器上运行。 I need to run the Selenium test suite during build process in jenkins and publish the results back in jenkins.我需要在 jenkins 的构建过程中运行 Selenium 测试套件并将结果发布回 jenkins。

I was able to run all the junit/testng test cases during build process and able to publish the results in jenkins except the selenium scripts.我能够在构建过程中运行所有 junit/testng 测试用例,并且能够在 jenkins 中发布结果,除了 selenium 脚本。

Can anyone suggest how to run selenium in linux box ?任何人都可以建议如何在 linux box 中运行 selenium 吗?

Basically to run selenium scripts via any CI tool needs to have build tool like ANT, MAVEN etc or any other tool which allows you to run selenium scripts using command line.基本上要通过任何 CI 工具运行 selenium 脚本,需要有构建工具,如 ANT、MAVEN 等或任何其他允许您使用命令行运行 selenium 脚本的工具。 Jenkins provides options to run shell scripts, windows batch commands, ant targets etc so If you can run tests via any one of above the ways then you can easily configure a job in Jenkins which will run the tests. Jenkins 提供了运行 shell 脚本、windows 批处理命令、ant 目标等的选项,因此如果您可以通过上述任何一种方式运行测试,那么您可以轻松地在 Jenkins 中配置将运行测试的作业。

An overview to run selenium tests in Jenkins:在 Jenkins 中运行 selenium 测试的概述:

  1. Locate your code pool in Jenkins Job.在 Jenkins Job 中找到您的代码池。 You can either use your local codebase or any version control system.您可以使用本地代码库或任何版本控制系统。

  2. As Jenkins provides options to run any command which can get executed from command line so you have to setup your selenium tests in such way that it can get executed from command line.由于Jenkins提供了运行任何可以从命令行执行的命令的选项,因此您必须以可以从命令行执行的方式设置 selenium 测试。 I'd suggest to use ANT for that.我建议为此使用ANT。 If you use ANT to run the tests then you can specify your build.xml path and ANT target in Jenkins and it will run that target for you.如果您使用 ANT 来运行测试,那么您可以在 Jenkins 中指定您的 build.xml 路径和 ANT 目标,它会为您运行该目标。

  3. Jenkins provides you option to publish HTML/Junit reports, so you just need to locate the path of report where it gets generated after test execution. Jenkins 为您提供了发布 HTML/Junit 报告的选项,因此您只需要找到测试执行后生成报告的路径即可。 Jenkins will publish those report for you. Jenkins 将为您发布这些报告。

As you said Jenkins setup exist on linux box, so you need to make your tests compatible to linux machine.正如您所说的 Jenkins 设置存在于 linux 机器上,因此您需要使您的测试与 linux 机器兼容。 You have to instantiate drivers considering linux machine or you can setup a Jenkins windows slave which will allow you to run tests on windows machine.考虑到 linux 机器,您必须实例化驱动程序,或者您可以设置一个Jenkins windows slave ,它允许您在 windows 机器上运行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM