1

I can use selenium IDE to make a test for any website using firefox. I want to use the script created for selenium IDE firfox for testing the same website using chrome. Since there are no reliable IDEs for IE and Chrome, I thought of using the workaround below -

1 - Create a firefox selenium IDE script/test and convert it to Java (I know java well). 2 - Modify the Java code a little to run on any browser instead of FF.

I only need a rough solution. I don't want to learn selenium web driver API in detail because I am not supposed to. I got an answer to (1) here - How to convert commands recorded in selenium IDE to Java?

How do I so part (2) ? Is my approach okay ? I only want to use selenium because there is plenty of documentation and books for it.

Community
  • 1
  • 1
big_space
  • 71
  • 2
  • 10
  • If you "know java well", why "I don't want to learn selenium web driver API in detail because I am not supposed to"? That makes absolutely no sense! – SiKing Oct 31 '14 at 19:40
  • @SiKing - I only want to make some temporary script for a small web test. I don't want to become a QA automation developer. That is why. Please give me +1. I got a -1 for no reason. I am a beginner. I can't get everything right. – big_space Nov 03 '14 at 05:59

2 Answers2

2

You want to use selenese-runner-java (SRJ).

Features

  • Run test cases or test suites created with Selenium IDE
  • Run tests from Java code directly
  • Run tests from command line
  • Support the most common drivers (firefox (default), chrome, ie, phantomjs ...)
  • Support of custom drivers through WebDriverFactory
  • Can be embedded in a maven build process (useful also for continouous integration process)
  • Since 1.7.0 : Support custom commands with the use of an implementation of CommandFactory

Sample usage

Firstly create your test (case and/or suite) with selenium IDE and save them on your disk.

1) Run tests from command line

java -jar selenese-runner.jar               \
     --driver chrome                        \
     --chromedriver path/to/chrome-driver   \
     path/to/my-test.html

2) Run tests programmatically

public static void main(String[] args) {
    String[] myArgs = new String[] { //
    //
       "--driver chrome", //
       "--chromedriver path/to/chrome-driver", //
       "path/to/my-test.html"
    };

    jp.vmi.selenium.selenese.Main.main(myArgs);
}

3) Run selenium tests as part of a Maven build process

Selenium tests are typically run during the integration-test phase. Moreover, selenese-runner-java must be part of the pom.xml dependencies.

...
<properties>
    <exec.maven.plugin.version>1.3.2</exec.maven.plugin.version>
    <selenese.runner.java.version>x.y.z</selenese.runner.java.version>
    <speed>0</speed><!-- Tests speed in milliseconds (Fast: 0, Slow: 5000) -->
</properties>

...
<dependency>
    <groupId>jp.vmi</groupId>
    <artifactId>selenese-runner-java</artifactId>
    <version>${selenese.runner.java.version}</version>
</dependency>

...
<build>
    <plugins>
       <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>${exec.maven.plugin.version}</version>
          <executions>
             <execution>
                <id>Execution Tests Selenium</id>
                <phase>integration-test</phase>
                   <goals>
                      <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>java</executable>
                        <includePluginDependencies>true</includePluginDependencies>
                        <includeProjectDependencies>true</includeProjectDependencies>
                        <classpathScope>test</classpathScope>
                        <longClasspath>true</longClasspath>
                        <commandlineArgs>
                            <!-- CDATA is crucial here... -->
                            <![CDATA[-cp selenese-runner-java-${selenese.runner.java.version}.jar jp.vmi.selenium.selenese.Main --driver chrome --chromedriver path/to/chrome-driver --baseurl http://localhost:8080 --set-speed ${speed} src/test/TestSuite.html --html-result target/selenium-reports]]>
                        </commandlineArgs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Stephan
  • 41,764
  • 65
  • 238
  • 329
0

There is no easy way of doing it without webdriver. If you really don't want to do it then you probably have to write your own tool. I am not sure why you don't want to learn selenium webdriver api. If you know Java it would take you couple of days to be in a good shape

Saifur
  • 16,081
  • 6
  • 49
  • 73