我尝试使用robotframework-2.8.6 jar运行测试用例,如下所示
java -jar robotframework-2.8.6.jar testcases
但它没有认识到selenium2关键字。如何将selenium2library与robotframework jar一起使用?
答案 0 :(得分:0)
使用机器人框架jar文件的最简单(也是最强大/可增强)的方法是通过maven插件。
(我假设你有一个maven运行时)
只需创建一个使用该插件的pom文件,然后使用mvn install
运行它添加selenium 2只需要在pom文件中添加依赖项。
示例(含有硒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>
答案 1 :(得分:0)
使用classpath命令我能够运行测试用例。
java -cp robotframework-2.8.6.jar org.robotframework.RobotFramework testcase