Jenkins与Selenium WebDriver集成的测试指南

Selenium is a tool broadly used for automated testing of web applications. One stage ahead, incorporating the selenium Jenkins integration takes it to the next level.

Selenium是广泛用于Web应用程序自动化测试的工具。 将SeleniumJenkins集成到一个新的阶段将其提升到一个新的水平。

Jenkins is an open source tool written in Java that gives constant conveyance and consistent integration benefits for software advancement. It automates manual tasks of your code arrangement processes from the advancement box – QA – Stage – Production. Jenkins underpins numerous modules which you can coordinate, for example, Git, SVN; manufacture the pipeline and more.

Jenkins是用Java编写的开源工具,可为软件开发提供持续的传递和一致的集成优势。 它从进度框– QA –阶段–生产中自动执行代码排列过程的手动任务。 Jenkins支持许多您可以协调的模块,例如Git,SVN; 制造管道等。

The fundamental functionality of Jenkins is to execute a predefined rundown of steps on the premise of time and a few events. For instance, when you need to construct an execution relying on time, you can run work at regular intervals, or if you need to build an event, you can do so after another confer in a Git repository.

Jenkins的基本功能是在时间和一些事件的前提下执行预定义的步骤概要。 例如,当您需要构造一个依赖时间的执行时,可以定期运行工作,或者,如果您需要构造一个事件,则可以在Git存储库中再进行一次授予。

Selenium詹金斯集成的好处是: (Benefits of selenium Jenkins integration are:)

  • It is cross-stage and can be used on a Mac OS, Windows, Linux, and Solaris.

    它是跨阶段的,可以在Mac OS,Windows,Linux和Solaris上使用。
  • It is a free and open source tool.

    它是一个免费的开源工具。
  • Utilized and all around reported.

    已被利用,各地都有报道。
  • Reconciliation with a wide assortment of technologies and tools.

    与各种各样的技术和工具进行协调。

Selenium Jenkins集成的逐步指南: (Step by step guide of Selenium Jenkins integration:)

第1节-下载Jenkins (Section 1-Download Jenkins)

First Step - Navigate to the official Jenkins Home Page website.

第一步-导航至Jenkins主页的官方网站。

Second Step - Download the Jenkins Java Web Archive (as shown below) and save to desktop or other temporary location.

第二步-下载Jenkins Java Web存档(如下所示)并保存到桌面或其他临时位置。

Third Step - You will next need to execute the "jenkins.war" file that you downloaded.

第三步-接下来,您需要执行下载的“ jenkins.war”文件。

Section 2 - How to design Jenkins integration with selenium WebDriver:

第2部分-如何设计Sennium WebDriver与Jenkins集成:

First Step - Go to the location where you saved jenkins.war

First Ste p-转到保存jenkins.war的位置

Second Step - Open Command incite known as CMD and explore the project home catalog. Start Jenkins selenium server.

第二步-打开称为CMD的Command命令,并浏览项目主目录。 启动JenkinsSelenium服务器。

Begin cmd> Project_home_Directory> java – jolt Jenkins.war

开始cmd> Project_home_Directory> java –震撼Jenkins.war

Third Step - When the Jenkins server is up and running; you will get a success message.

第三步-当Jenkins服务器启动并运行时; 您将收到一条成功消息。

By default, Jenkins keeps running on Port 8080 so you can explore the URL below for the Jenkins UI (User Interface)

默认情况下,Jenkins始终在端口8080上运行,因此您可以浏览下面的Jenkins UI(用户界面)URL

Open the UI by browsing to "http://localhost:8080" in your web browser

通过在Web浏览器中浏览到“ http:// localhost:8080”来打开UI

Jenkins is now up and running, so we need to configure it with the goal of being able to execute our test case using the Jenkins selenium plugin.

Jenkins现在已启动并正在运行,因此我们需要对其进行配置,以能够使用Jenkins selenium插件执行测试用例。

Fourth Step - When Jenkins and selenium are running we are practically done, however, before creating the build, we have to configure Jenkins so that it can recognize different tools like Java, Maven and so on.

第四步-当Jenkins和selenium运行时,实际上已经完成了,但是,在创建构建之前,我们必须配置Jenkins,以便它可以识别Java,Maven等不同的工具。

Click on > Manage Jenkins

单击>管理詹金斯

Click on > Configure System

单击>配置系统

Here we are telling Jenkins that our java is at this location.

在这里,我们告诉詹金斯,我们的Java就是在这个位置。

Browse to the JDK area and Click on the "Add JDK" button

浏览到JDK区域,然后单击“添加JDK”按钮

Uncheck the "Install automatically" check box so Jenkins will just take java previously specified.

取消选中“自动安装”复选框,这样Jenkins将使用先前指定的Java。

Give the name as "JAVA_HOME" and specify the "JDK" path.

命名为“ JAVA_HOME”并指定“ JDK”路径。

In selenium continuous integration of Jenkins, you can arrange an email notice for the client. This is discretionary, but if you need to design Email notifications, then you need to configure some settings.

在Jenkins的Selenium持续集成中,您可以为客户安排电子邮件通知。 这是自由决定的,但是如果您需要设计电子邮件通知,则需要配置一些设置。

Refer to the screenshot below to see where you can change the mail server login details - and then click on "Apply"

请参考下面的屏幕截图,以查看可以在何处更改邮件服务器登录详细信息-然后单击“应用”

Refer to screenshot you can change login details and tap on Apply. selenium jenkins integration

Once done click on “Apply” and “Save”

完成后,单击“应用”和“保存”

Well done, your selenium web driver integration with Jenkins is now configured.

做得好,您的Selenium Web驱动程序与Jenkins的集成现已配置。

第3部分-执行JenkinsSeleniumWeb驱动程序TestNG (Section 3 - Execute Jenkins selenium web driver TestNG)

We can execute test cases with Jenkins in four ways

我们可以通过四种方式使用Jenkins执行测试用例

In this post, we will execute Jenkins with a Windows batch command

在本文中,我们将使用Windows批处理命令执行Jenkins

First Step - Create a batch file first, then add a similar cluster record to Jenkins

第一步-首先创建一个批处理文件,然后向Jenkins添加类似的群集记录

A - To make the batch file, we have to set a classpath of TestNG so that we can execute testng.XML records

A-要创建批处理文件,我们必须设置TestNG的类路径,以便我们可以执行testng.XML记录

Our task structure should resemble the following;

我们的任务结构应类似于以下内容;

B - Open command provokes and sets the classpath

B-打开命令会激发并设置类路径

While setting the classpath, set the way of canister envelope and libs organizer

设置类路径时,设置容器信封和libs Organizer的方式

Home index > set classpath=C: \Users\Learn-automation\bin;C:\Users\Learn-automation\libs\*;

主页索引> set classpath = C:\ Users \ Learn-automation \ bin; C:\ Users \ Learn-automation \ libs \ *;

C - Open notepad and write the underneath command and save as .bat document

C-打开记事本并编写下面的命令,然后另存为.bat文档

java – cp bin;libs/* org.testng.TestNG testng.XML

java – cp bin; libs / * org.testng.TestNG testng.XML

Second Step - Make a task in Jenkins which will execute our build

第二步-在Jenkins中执行一个任务,该任务将执行我们的构建

Use Jenkins UI to program (sort http://localhost:8080) 

使用Jenkins UI进行编程(对http:// localhost:8080进行排序)

A - Click on "New Item"

A-点击“新项目”

B - Give the Task a Name, select "Build a free-style software project" and Click the “OK” button

B-为任务命名,选择“建立自由样式的软件项目”,然后单击“确定”按钮

C - Navigate to "Advanced Project Options" > Check "Use custom workspace" > In "Directory" provide the project home catalog path

C-导航到“高级项目选项”>选中“使用自定义工作区”>在“目录”中提供项目主目录路径

D - The important part now is to determine which "Add Build step"  to use > Click on "Execute Windows batch command"

D-现在重要的部分是确定要使用的“添加构建步骤”>单击“执行Windows批处理命令”

E - In the following area, enter the batch file name you made, and Click on "Apply" & "Save"

E-在以下区域中,输入您创建的批处理文件名,然后单击“应用”和“保存”

Third Step - You can now run the Build > Click on "Build Now"

第三步-您现在可以运行Build>点击“ Build Now”

Fourth Step - Check Build history and Console output to confirm the outcome

第四步-检查构建历史记录和控制台输出以确认结果

Selenium Jenkins integration gives you the ability to run your script each time there is any change in software code and conveys the code in another condition. With Jenkins, you can save execution history and test reports.

Selenium Jenkins集成使您能够在软件代码发生任何更改时运行脚本,并在另一种情况下传递代码。 使用Jenkins,您可以保存执行历史记录和测试报告。

So, trigger selenium from Jenkins is extremely valuable when you have test cases prepared, and you need them to run with just a single click. We can make or schedule work to run the test cases using a batch document.

因此,当您准备好测试用例时,Jenkins的触发Selenium非常有价值,您只需单击一下即可运行它们。 我们可以使用批处理文档来安排或安排工作来运行测试用例。

翻译自: https://www.experts-exchange.com/articles/31748/Testing-Guide-of-Jenkins-Integration-with-Selenium-WebDriver.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值