Forum Discussion

sumitmishra's avatar
sumitmishra
Occasional Contributor
15 years ago

SoapUI integration with seleniumRC

I was able to integrate Selenium-RC with SoapUI by directly using the java client driver provided by thoughtworks (DefaultSelenium class). Only tweak that I did was to create my own wrapper class around it and make it a singleton. This allowed me to use the Selenium handle across test steps thus allowing me to implement my automation in a more modular fashion.

Without the wrapper I am forced to code my entire UI scenario in a single step as i can't pass the selenium handle around. Singleton solves this problem, but the problem with making it a singleton is that you can have only one instance running and so cannot have multiple browser sessions going on simultaneously.

I am not a java programmer, and so the wrapper class singleton implementation is basic and solves my purpose. i just wanted to share this information in this forum as I spent quite sometime looking around for such a solution.

2 Replies

  • sumitmishra's avatar
    sumitmishra
    Occasional Contributor
    Here is the warpper class:
    package tools;
    import com.thoughtworks.selenium.*;
    import java.util.regex.Pattern;


    public final class Browser {

    private static Browser instance;
    private Selenium selenium;
    private boolean inuse;

    private Browser (String host,int port, String browserType, String url) {
    this.selenium = new DefaultSelenium(host, port, browserType, url);
    this.selenium.start();
    inuse = true;
    }

    public static Browser getInstance(String host, int port, String browserType, String url) {
    if (instance == null) {
    instance = new Browser(host,port,browserType,url);
    }
    return instance;
    }

    public void open(String url) {
    this.selenium.open(url);
    }

    public xxxx() {}.....
    }



    Here is how you call it in a groovy test step in soapUI:

    import com.thoughtworks.selenium.*;
    import tools.*;

    Browser selenium = Browser.getInstance(host,port,type,url);
    selenium.open(url);
    selenium.xx
    ....


    and so you can use your selnium handle throughout your soapUI project. Make suer to close it when you're done using it or when you encounter exception.