So I got my environment set up and I have been busy coding up new Selenium-WebDriver test suite for a few weeks now.
I first wanted to just state that as great of a tool as SoapUI is, their community support just plain sucks! Any time I navigate to their discussion fora, I can actually hear the crickets in the distance. If you need some help, may I recommend the Service Testing using soapUI (needs login) group at LinkedIn.
The next bit of complaint that I have with SoapUI, is how poorly it integrates with Eclipse!
Now back to your regular programming …
the quick and dirty
So the most obvious, and perhaps the easiest way, to get Selenium and SoapUI to cooperate is:
- Install SoapUI.
- Download Selenium (you need the selenium-server-standalone-2.*.jar) and drop it into your SoapUI installation (into %SOAPUI_HOME%\bin\ext).
- Fire up SoapUI; start a new Project; create a new test case; add a new Groovy step; copy-paste the sample code into the step. I made a few modification: drop the
packageline, drop theclass Selenium2Exampleandvoid mainlines along with the closing brackets, and change theSystem.out.printlntolog.info. My final (full) test code is below. - Click Play. You should see Firefox starting up, navigating to Google, and afterwards you should see the SoapUI log entries.
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.support.ui.ExpectedCondition
import org.openqa.selenium.support.ui.WebDriverWait
// Create a new instance of the Firefox driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new FirefoxDriver()
// And now use this to visit Google
driver.get("http://www.google.com")
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"))
// Enter something to search for
element.sendKeys("Cheese!")
// Now submit the form. WebDriver will find the form for us from the element
element.submit()
// Check the title of the page
log.info("Page title is: " + driver.getTitle())
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!")
}
});
// Should see: "cheese! - Google Search"
log.info("Page title is: " + driver.getTitle())
//Close the browser
driver.quit()
Success, the two can talk to each other.
You will probably notice some errors, due to Google updating their site and the above code no longer works there; however, the proof of concept is there. For a better example, see my sample code.
the difficult way
I did not get as much chance to play with the SoapUI as I would have liked, but I wanted to get this published. The above will work for simple Selenium steps. However, for more complex steps you probably want a little more.
Unfortunately, I have not had a chance to explore this yet, but the general idea is:
- SoapUI is a java project, it must be in some .jars somewhere, hopefully in just one.
- Import that into your Groovy (Java) project.
- Then you should be able to call appropriate functions from your code.
All this sounds quite easy, but I am certain that it will need more than what I have here. If anyone manages to get this to work, I would be really curious to hear from you.





[...] To Get Selenium and SOAP Ui to cooperate [...]
Pingback by Selenium Web Driver – SOAP UI Integration for Web Service Testing. | Selenium Script — April 9, 2013 @ 8:53 am |
Is there any way to customize this code to IE or Chrome?
Comment by Chandrasekaran — September 13, 2012 @ 4:43 am |
I have a very basic Selenium framework that I use. You can find the source @ sebase.sourceforge.net. The code that specifically handles different browser “selection” is here: http://sebase.svn.sourceforge.net/viewvc/sebase/sebase-groovy/tests-groovy/korporation/sebase/framework/FrameworkHelper.groovy?revision=120&view=markup
Comment by siking — September 13, 2012 @ 9:49 am |
No words to say.. Awesome.. i just followed the step..Sweet
Comment by Chandrasekaran — September 12, 2012 @ 1:35 pm |
Nice try.. will try to integrate the 2 testing Giants together having different expertize (UI and Services) to make a robust testing framework..
OGK…
Comment by Gaurav — January 10, 2012 @ 11:45 pm |
Thanks for the post, its a good starter for soap UI and Selenium integration
Regards,
Rakesh.P
Comment by rakesh — October 18, 2011 @ 11:03 pm |