0
votes

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 ?

2

2 Answers

0
votes

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>
0
votes

Using classpath command I was able to run the testcases.

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