[英]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.