SOAPUI Introduction
Before getting into the depth of our topic ‘Integrate SOAPUI with Selenium’, lets first get familiar with each of its term.
SOAP is an XML -based protocol, it allows applications to exchange information over HTTP and uses WSDL (Web Services Description Language) for communication.
SOAPUI is an open source web service testing tool widely used for API testing. It is compatible with multiple platforms. The most prominent feature of this tool is that it supports all types of protocols and technologies. SOAPUI-pro is advanced of it having additional functionalities which are essential for organizations dealing with critical web services.
Selenium Webdriver
Selenium is also the most widely used open source tool for automating testing over browsers. It automates browsers across multiple platforms.
Selenium WebDriver supports many browsers including headless HTMLUnit Browser, PhantomJs. In addition to it, it supports multiple programming languages too.Selenium Webdriver communicates directly with the browser instance and there is no need for a server.
Integrate Selenium with SOAPUI
SOAPUI can be integrated with Selenium for enhancing functionalities. The simplest and easiest way to integrate Selenium with SOAPUI is to use ‘Groovy’. SOAPUI completely supports Groovy.
Groovy is an object-oriented scripting language which is based on Java Platform. Groovy has the following features:
- Support for both static and dynamic typing
- Support for operator overloading
- Native syntax for lists and associated arrays
- Can use existing Java libraries
- It extends the java.lang.Object
Pre-requisites for using Selenium with SoapUI
- Download Groovy SDK
- Install Java SDK
- Install Selenium
- Install SOAPUI Pro
Getting Started with ‘SOAPUI – Selenium’
Procedure for executing the code:
- Startup SOAPUI
- Start a new test case
- A new Groovy step should be added
- Copy-paste the below sample code into the step
- Click Play
- Firefox will start up and navigate to Google. And now you can view the SOAPUI log entries
- The code runs using JUnit.
SAMPLE CODE:
@when(“<I use the weather service to get the weather information”) public void i_use_the_weather_service_to_get_the_information() { Set<Entry<String, string>> set = zipAndCities.entrySet(); while (iterator,hasNext)) { Entry<String, String> entry = iterator.next(); String zipCode = entry.getkey(); String city = entry.getValue(); String[] prop = {“usePropertyFileFlag=true”,”zipCode=” +zipCode, “city=” +city}; try { SoapUITestCaseRunner soapUITestCaseRunner = new SoapUITestCaseRunner(); soapUITestCaseRunner.setProjectFile(“src/test/resources/WeatherSoapTest-soapui-project.xml”); soapUITestCaseRunner.setProjectProperties(prop); soapUITestCaseRunner.setTestSuite(“TestSuite1″); soapUITestCaseRunner.setTestCase(“TestCase1″); soapUITestCaseRunner.run(); } catch (Exception e) { System.err.println(“checking” + zipCode + ” failed!”); failureCount++; zipCodes.append(zipCode + ” [” + city +”] “); e.printStackTrace(); } finally { totalCount++; } } } }
Every action that took place will get register in log files in console view thus enabling us to have a glance at all the test cases executed. You will find a list of zip codes, cities fetched and passed into the SoapUI Test Case.
This is all about how to Get started with ‘Integration of SOAPUI with Selenium’. I hope I am able to explain you well. Please feel free to share your feedback with us using the comment section.
Thank You! Have a nice day