Disclaimer : This post was in my DRAFT for almost 8+ month and i happened to check my blog DRAFTS today hence clearing this. Please do excuse the delay in the response to your queries, i will try to post answers now.

Having worked on selenium tool for almost 4 month and being an addicted soapUI tester, i thought it would be great if both these tool can work together. Lately, after having spent some amount of time i found the way to go for it.

Before starting on integration of soapUI & Selenium, i had to find a common link & it was none other than GROOVY.

Yes, Selenium WebDriver supports groovy & soapUI is having a smooth integration with Groovy. So this is the common factor to go with. So start with the writing the code, download the GROOVY SDK, JAVA SDK, Selenium Standalone Driver & any IDE which support Groovy. Put the downloaded Selenium Standalone driver.jar file into the soapui/bin & soapui/lib folder before executing the  scripts.

Download links : 

Groovy SDK : http://groovy.codehaus.org/Download
Selenium Standalone : http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.25.0.jar&can=2&q=
JAVA SDK : From Sun/Oracle website, download latest.

My Conclusion :
Best API test tool + Best Web Automation tool = GREATNESS in testing Web API application End to End.

/*
@Author : Pradeep Bishnoi
@Description : .
@GroovyTestStepName : "Launch Selenium"
*/
import org.openqa.selenium.By
 import org.openqa.selenium.WebDriver
 import org.openqa.selenium.WebElement
 import org.openqa.selenium.ie.InternetExplorerDriver
 import org.openqa.selenium.ie.InternetExplorerElement
 import org.openqa.selenium.support.ui.ExpectedCondition
 import org.openqa.selenium.support.ui.WebDriverWait
 import org.openqa.selenium.OutputType
 import org.apache.commons.io.FileUtils
 import org.openqa.selenium.Keys

WebDriver driver = new InternetExplorerDriver()   //This will launch IE, for Firefox use --> FirefoxDriver()

try
{
driver.get("https://learnsoapui.wordpress.com") // Url to be opened
 log.info driver.getSessionId().toString()

 WebElement element = driver.findElement(By.id("s"))
 element.sendKeys("Assertion")

 File f1 = driver.getScreenshotAs(OutputType.FILE)
 FileUtils.copyFile(f1, new File("c:\\screenshot1.png")); // Location to save screenshot

 element.submit()

 driver.getKeyboard ().pressKey (Keys.DOWN)
 driver.getKeyboard ().pressKey (Keys.DOWN)
 driver.getKeyboard ().pressKey (Keys.DOWN)
 driver.getKeyboard ().pressKey (Keys.UP)
 driver.getKeyboard ().pressKey (Keys.UP)
 driver.getKeyboard ().pressKey (Keys.UP)
}
catch(Exception e)
{
log.info "Exception encountered : " + e.message
}
Advertisements
Comments
  1. margaret thomas says:

    Awesome! This is great for users who must test both their web clients and their webservice API….I wish I had known this when I worked with soapUI and Selenium,,,instead of the method we used to work with the WebService API

  2. Gopishankar says:

    Awesome buddy. Its an awesome article for starters like me..

  3. vinoth says:

    I tried the same and i am getting the follwoing error

    rg.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: ‘2.28.0’, revision: ‘18309’, time: ‘2012-12-11 20:21:18’ System info: os.name: ‘Windows XP’, os.arch: ‘x86’, os.version: ‘5.1’, java.version: ‘1.7.0_02’ Driver info: driver.version: InternetExplorerDriver error at line: 26

    But please note that IE opens.. but this error stops the script. Any thought on tihs?

  4. GaneshSB says:

    Hi pradeep ,

    I tried the same with SOAPUI 4.5.1 ,FF 20 and selenium-server-standalone-2.32.0.jar , but getting the UnreachableBrowserException.

    Any thoughts or help on this would be great help.

  5. Shrikant says:

    Hi All,

    I tried this also and getting the same error:

    org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: ‘2.35.0’, revision: ‘8df0c6b’, time: ‘2013-08-12 15:43:19’ System info: os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_02’ Driver info: driver.version: FirefoxDriver error at line: 50

    Any solution for this error?

    Thanks,
    Shrikant

    • Kevin Swift says:

      Hello, the one change I had to make was to run selenium in Firefox instead of IE. So, simply change
      import org.openqa.selenium.ie.InternetExplorerDriver
      import org.openqa.selenium.ie.InternetExplorerElement
      to
      import org.openqa.selenium.firefox.FirefoxDriver;

      and change WebDriver driver = new InternetExplorerDriver()
      to
      WebDriver driver = new FirefoxDriver();

      Then everything seems to be running fine for me.

  6. Prashant Asthana says:

    I tried doing this. But in simple recording using IDE, its not recording the steps I am performing on soap ui. Can you please help me in this regard?

  7. Saravanan says:

    Excellent Pradeep. Tried with versions Soapui5.0, selenium-standalone-server-2.41.0 and Firefox31.0. It all worked. For those seeing errors like ‘Could not start a new session’, ‘unreachable browsers’, please try to reinstall firefox. That has the solved the issue for me.

  8. Yury says:

    Can we call class with selenium checks from soap ui program?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s