【问题标题】:Eclipse for Robot Framework (java version) project: how to run specific tags?Eclipse for Robot Framework(java 版)项目:如何运行特定标签?
【发布时间】:2017-12-12 23:54:49
【问题描述】:

我的项目使用 Maven 来引用所有需要的库,所以我什至不需要手动安装机器人框架(我只是在 pom.xml 中包含了 markusbernhardt 的 Selenium2Library 作为依赖项):

  <dependencies>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.4.0</version>
    </dependency>
    <dependency>
      <groupId>com.github.markusbernhardt</groupId>
      <artifactId>robotframework-selenium2library-java</artifactId>
      <version>1.4.0.8</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.robotframework</groupId>
        <artifactId>robotframework-maven-plugin</artifactId>
        <version>1.4.7</version>
        <executions>
          <execution>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

我可以使用 Maven 安装或使用 Maven 的运行配置来运行我的测试:

但是,我不知道如何告诉机器人框架我要运行带有特定标签的测试。我没有从命令行运行机器人框架,因为我的机器上没有安装机器人框架,我只是将它用作 maven 依赖项,所以我无法运行 python -m robot.run --include tag

我尝试在运行配置中添加--include tag 作为参数,但它被忽略了。

有没有办法在 Eclipse 中将此标签参数发送给机器人?

【问题讨论】:

    标签: eclipse robotframework ui-automation


    【解决方案1】:

    刚刚知道怎么做!在此处留下信息以防对其他人有帮助:

    都在 pom.xml 中:

    添加一个&lt;properties /&gt;first-level 元素(在&lt;project /&gt; 内),其中包含您选择的属性名称和要运行的标记,如下所示:

    <properties>
      <robot-tag>mytag</robot-tag>
    </properties>
    

    然后,在插件部分,robotframework-maven-plugin plugin 元素,添加这个:

    <configuration>
      <includes>
        <include>${robot-tag}</include>
      </includes>
    </configuration>
    

    就是这样。运行配置不需要更改。并且该项目也可以作为 Maven Install 运行。

    这就是我的 pom.xml 现在的样子(去掉元素和项目特定的信息,如 groupID、artifactID 等):

      <properties>
        <robot-tag>debug</robot-tag>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.seleniumhq.selenium</groupId>
          <artifactId>selenium-java</artifactId>
          <version>3.4.0</version>
        </dependency>
        <dependency>
          <groupId>com.github.markusbernhardt</groupId>
          <artifactId>robotframework-selenium2library-java</artifactId>
          <version>1.4.0.8</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.robotframework</groupId>
            <artifactId>robotframework-maven-plugin</artifactId>
            <version>1.4.7</version>
            <executions>
              <execution>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <includes>
                <include>${robot-tag}</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>  
    

    【讨论】:

      猜你喜欢
      • 2020-03-27
      • 2021-01-14
      • 1970-01-01
      • 2017-03-11
      • 1970-01-01
      • 2013-07-30
      • 2011-03-02
      • 2021-01-19
      • 1970-01-01
      相关资源
      最近更新 更多