LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

How can I automate Soap UI tests using Selenium?

Can anyone please explain me how can I automate Soap UI tests using Selenium.

Up Vote Down Vote 0 Votes
Posted 4 months ago

Answers


The simplest and easiest way to integrate Selenium with Soapui is to use Groovy. SoapUI extensively supports Groovy.

Groovy is an object-oriented scripting language. Groovy includes all the Java libraries. So all Java related keywords and functions can be used in the groovy script directly. It integrates with JVM (Java Virtual Machine).

Pre-requisites for using Selenium with SoapUI

  • Download Groovy SDK:
  • Install Java SDK
  • Install Selenium
  • Install SoapUI Pro Call the SoapUI Testcase runner in Selenium.

The below code will be used to call SoapUI testcase. It will set the properties of city and corresponding zip codes. When the code is executed, it will get the value of cities and zip codes. Also, display the failure count that does not match with the corresponding city and zip code. This code will run in Selenium.

Note: "usePropertyFileFlag=true" here instead of using a static property file to store zip code and city. The information of zip code and city will pass at runtime dynamically by setProjectProperties() method.

Instructions to run the code.

  • Start up SoapUI
  • Start a new test case
  • Add a new groovy step.
  • Copy paste the sample code into the step.
  • Click on Play.
  • You can see Firefox starting up and navigating to Google. After that, you can see SoapUI log entries.
  • Code runs using Junit Code Example
@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++;
            }
}
}
}

The console view enables 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 1.

View SoapUI Log file

Log files record every action occurred in the operating system or software application. To view, SoapUI log files. Go to the main directory and you will see a file name "soapui.log."

In SoapUI, the log file is located in the bin folder in the installation directory. E.g C:\Program files\SmartBear\soapUI-Pro-4.0.1\bin

When you open this log file by clicking on it, it will look similar to the screenshot below.

Summary

  • Soap is simple XML-based protocol. It allows the exchange of information over HTTP.
  • SoapUI is an open source cross-platform web service testing tool.
  • Selenium is a suite of test tools to automate browsers across many platforms.
  • Selenium Webdriver makes direct calls to the browsers. It uses browsers native support for automation.
  • Selenium integrates with SoapUI using Groovy.
Up Vote Down Vote 0 Votes
Posted 2 months ago