【问题标题】:Running Parallel test on different configuration with Maven, Gauge-Java framework使用 Maven、Gauge-Java 框架在不同配置上运行并行测试
【发布时间】:2019-12-10 18:34:21
【问题描述】:

当我尝试在 LambdaTest Selenium Grid 上运行时,我的测试是按顺序运行的,但不是并行运行的。 下面是我的 maven pom 文件的一小部分:

<executions> 
                        <execution>
                        <id>test-chrome</id>
                        <phase>test</phase>
                        <configuration>
                            <env>chrome</env>
                            <inParallel>true</inParallel>
                            <nodes>4</nodes>
                            <specsDir>specs</specsDir>
                        </configuration>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>test-firefox</id>
                        <phase>test</phase>
                        <configuration>
                            <env>firefox</env>
                            <inParallel>true</inParallel>
                            <nodes>4</nodes>
                            <specsDir>specs</specsDir>
                        </configuration>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        </execution>
</executions>

我为 chrome 和 firefox 创建了 2 个不同的目录,其中包含两个不同的属性文件:

chrome.properties 文件:

BROWSER = chrome
BROWSER_VERSION = 78
PLATFORM = WIN10

firefox.properties 文件:

BROWSER = firefox
BROWSER_VERSION = 69
PLATFORM = WIN8

我在我的 java 类文件中使用了这些环境变量:

DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", System.getenv("BROWSER"));
        capabilities.setCapability("version", System.getenv("BROWSER_VERSION"));
        capabilities.setCapability("platform", System.getenv("PLATFORM"));

任何帮助将不胜感激,非常感谢:)

【问题讨论】:

    标签: java maven selenium gauge getgauge


    【解决方案1】:

    尝试用这个替换 chrome.properties:

    BROWSER = chrome (PropertyName)
    BROWSER_VERSION = 78 
    PLATFORM = WIN10
    

    并从属性文件或您想要动态化的任何其他参数中添加驱动程序版本

    <plugin>
         <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
             <parallel>tests</parallel>
              <threadCount>10</threadCount>
               <systemPropertyVariables>
                <propertyName>Firefox</propertyName>
                <propertyName>Chrome</propertyName>
              </systemPropertyVariables>
              <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
              </suiteXmlFiles>
    
            </configuration>
          </plugin>
    </plugins>
        </build>
      <dependencies>
        <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>6.8.8</version>
                <scope>test</scope>
            </dependency>
            <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.47.1</version>
    </dependency>   
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>2.47.1</version>
    </dependency>
            <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.47.1</version>
        </dependency>  
    </dependencies> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-30
      • 2021-01-16
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      • 2013-10-19
      相关资源
      最近更新 更多