The software industry has adopted Service Oriented Architecture-SOA, which consist of Microservices consist of SOAP and REST.
Selenium is an API which helps in Web automation, Selenium does not help in API testing although SoapUI scripts can be invoked from selenium/Java classes.
Using below 3 steps SOAPUI project can be triggered from java class-
Step 1- Open command prompt form java class
Step 2- Move to Bin directory of SOAPUI folder where Testrunner.bat is placed
Step 3- Run Project.xml
Above steps will trigger SOAPUI project xml
//If complete soap project is required to execute
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "cd "+C:\Programfiles\SmartBear\SoapUI-5.4.0\bin" && testrunner.bat C:\SoapProject\Project.xml")
//If specific test case is required to execute
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "cd "+C:\Programfiles\SmartBear\SoapUI-5.4.0\bin" && testrunner.bat -c"TestCaseName" C:\SoapProject\Project.xml")
//Below piece of code will display command prompt execution in Eclipse console
Process p builder.start();
BufferReader r = new BufferReader(new InputStreamReader(p.getInputStream()))
So once execution is completed, using above code selenium verification can be triggered.
SOAP and REST services can also be automated using java classes and responces can be pasred so that meaningful node can be processed further.
Couple of Questions and their Answers
1- Can SOAP and REST Services be automated using Selenium-
Answers – No, Selenium can only do web Automation, Although using ResrAssured-REST Services can be automated within Selenium project
1- Difference between API and Web Testing
Answer- API does not have User Interfase or we can say it work using xml/json format where as in Web Testing proper HTML is being using and a User Interface is available for functionalities.