使用硒testNG在不同的浏览器中并行运行功能黄瓜 [英] Running features cucumber in parallel in different browser using selenium testNG

查看:197
本文介绍了使用硒testNG在不同的浏览器中并行运行功能黄瓜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用testNG和Selenium或Cucuming-JVM运行Cucumber功能 我是新手,但是在我重新学习之后,我认为黄瓜jvm对我而言无法在paralell中工作,我还添加了surefire插件

How can i run cucumber features using testNG and selenium or cucumber-JVM i'm new in this but after my researsh i think that cucumber jvm doesn't work in paralell for me i added also the surefire plugin

现在我尝试用TESTNG进行测试 我的testNg.xml:

now i try to test with TESTNG my testNg.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="run test in parallel Suite" parallel="tests" verbose="1" configfailurepolicy="continue" thread-count="2">

  <listeners>

        <listener classname="com.driver.LocalWebDriverListener" />
    </listeners>
    <test name="Tests in FF">
        <parameter name="browserName" value="firefox" />
        <classes>
            <class name="com.runner.RunnerTestInFirefox" />
        </classes>
    </test>
    <test name="Tests in Chrome" >
        <parameter name="browserName" value="chrome" />    
 <classes>
            <class name="com.runner.RunnerTestInChrome"/>
        </classes>
    </test>
</suite> <!-- Suite -->

然后我为Chrome创建2个类赛跑者,为Firefox创建另一个:

and i create 2 class runner one for chrome and the other for firefox:

package com.runner;

    import org.junit.runner.RunWith;

    import cucumber.api.CucumberOptions;
    import cucumber.api.junit.Cucumber;
    import cucumber.api.testng.AbstractTestNGCucumberTests;

    @RunWith(Cucumber.class)
    @CucumberOptions(
             features = {"/features"},
             glue={"stepsdefinition"})
    public class RunnerTestInChrome extends AbstractTestNGCucumberTests {

    }

当我运行测试时,浏览器镶边已打开和关闭,但我不解释为什么它没有采用该功能的网址和步骤!

when i run my test the browser chrome is open and closed but i don't why it didn't take the url and the steps in the feature!

推荐答案

Afaik Cucumber不支持并行执行,您可能需要使用其他插件或需要使用

Afaik Cucumber does not support parallel execution, You might need to use an additional plugin or need to use gherkin with qaf. qaf is built upon TestNG for functional test automation, providing browser management, resource management, data-driven capability, detailed reports with screenshot and command-log...

将小黄瓜与qaf一起使用时,您的配置文件可能如下所示:

When using gherkin with qaf, your configuration file may look like:

<suite name="run test in parallel Suite" parallel="tests" verbose="1" configfailurepolicy="continue" thread-count="2">
      <test name="Tests in FF">
            <parameter name="driver.name" value="firefoxDriver" />           
            <classes>
                  <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
            </classes>
      </test>
      <test name="Tests in Chrome">
            <parameter name="driver.name" value="chromeDriver"/>                      
            <classes>
                  <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
            </classes>
      </test>
</suite>

注意:如果要并行运行方案,请分别设置parallel="methods"thread-count.

NOTE: If you want to run scenarios in parallel set parallel="methods" and thread-count accordingly.

您可以通过逐步演练逐步教程

这篇关于使用硒testNG在不同的浏览器中并行运行功能黄瓜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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