简体   繁体   English

如何使用机器人框架jar文件运行测试用例?

[英]How to run test cases using robot framework jar file?

I tried running the testcases by using robotframework-2.8.6 jar like below 我尝试通过使用robotframework-2.8.6 jar运行测试用例,如下所示

java -jar robotframework-2.8.6.jar testcases

But Its not recognizing the selenium2keywords. 但是它不能识别selenium2关键字。 How do I use the selenium2library with robotframework jar ? 我如何将selenium2library与robotframework jar一起使用?

The easiest (and most robust/enhanceable) way to use the robot framework jar file is through the maven plugin. 使用机器人框架jar文件的最简单(也是最可靠/最增强)的方法是通过maven插件。

(I'm assuming here that you have a maven runtime) (我在这里假设您有一个Maven运行时)

Just create a pom file that uses the plugin and run it using mvn install 只需创建一个使用插件的pom文件并使用mvn install运行它

Adding selenium 2 becomes just a matter of adding a dependency to the pom file. 添加硒2只需将依赖项添加到pom文件即可。

Example (with selenium 2) which contains some useful tricks in it as well. 示例(硒2)中也包含一些有用的技巧。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0    
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

    <groupId>com.shtand</groupId>
    <artifactId>robot-framework</artifactId>
    <version>5.5.1</version>

    <properties>
       <logDir>${project.build.directory}/logs</logDir>
       <webdriver.chrome.driver>bin\\chromedriver.exe</webdriver.chrome.driver>
    </properties>
 <dependencies>
    <dependency>
        <groupId>com.github.markusbernhardt</groupId>
        <artifactId>robotframework-selenium2library-java</artifactId>
        <version>1.4.0.6</version>
    </dependency>
 </dependencies>

<build>
  <plugins>
                <plugin>
                    <groupId>org.robotframework</groupId>
                    <artifactId>robotframework-maven-plugin</artifactId>
                    <version>1.4.3</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <variables>
                                    <variable>RESOURCES:${project.basedir}/resources</variable>
                                    <variable>LIBRARIES:../common</variable>
                                    <variable>LOGDIR:${logDir}</variable>
                             </variables>
                                <extraPathDirectories>
                                    <extraPathDirectory>resources</extraPathDirectory>
                                    <extraPathDirectory>src/libraries/custom</extraPathDirectory>
                                    <extraPathDirectory>src/test/robotframework/acceptance/common</extraPathDirectory>
                                </extraPathDirectories>
                                <excludes>
                                    <exclude>NotImplemented</exclude>
                                </excludes>
                                <nonCriticalTags>
                                    <nonCriticalTag>BUG_OPENED</nonCriticalTag>
                                </nonCriticalTags>
                                <debugFile>${logDir}/robot_debug.log</debugFile>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
</build>

使用classpath命令,我能够运行测试用例。

java -cp robotframework-2.8.6.jar org.robotframework.RobotFramework testcase

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

相关问题 如何在机器人框架中运行特定的测试用例 - how to run specific test cases in robot framework 如何通过机器人框架一次(并行)运行多个测试用例 - How to Run multiple test cases at a time (in parallel) through robot framework Robot Framework:重新运行失败的测试用例 - Robot Framework: Re Run Failed Test Cases 使用jenkins运行selenium测试用例(测试用例在机器人框架中) - Running selenium test cases(Test cases are in robot framework) using jenkins 如何在 jenkins 中对失败的 Robot Framework 测试用例实现重新运行 - How to implement rerun on failed Robot Framework test cases in jenkins 即使出现错误,如何保留测试用例? 在机器人框架中 - How can I keep the test cases even if there is an error? in Robot Framework 使用Robot Framework Test在浏览器中上传文件 - Upload a file in browser using Robot Framework Test 减慢使用Robot Framework进行测试运行的好方法? - Good ways to slow down a test run using Robot Framework? 如何在使用 seleniumlibrary 的机器人框架测试用例中多次运行特定关键字? - How to run a particular keyword multiple times in a test case of robot framework using seleniumlibrary? 机器人框架 - 如何在测试运行期间使用 chrome 中的开发人员工具? - Robot framework - how to work with developer tools in chrome during test run?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM