How to run test cases using robot framework jar file?

霸气de小男生 提交于 2019-12-23 04:38:23

问题


I tried running the testcases by using robotframework-2.8.6 jar like below

java -jar robotframework-2.8.6.jar testcases

But Its not recognizing the selenium2keywords. How do I use the selenium2library with robotframework jar ?


回答1:


The easiest (and most robust/enhanceable) way to use the robot framework jar file is through the maven plugin.

(I'm assuming here that you have a maven runtime)

Just create a pom file that uses the plugin and run it using mvn install

Adding selenium 2 becomes just a matter of adding a dependency to the pom file.

Example (with selenium 2) which contains some useful tricks in it as well.

<?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>



回答2:


Using classpath command I was able to run the testcases.

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


来源:https://stackoverflow.com/questions/28041594/how-to-run-test-cases-using-robot-framework-jar-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!