Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke Selenium within SoapUI?

I have been tasked at work to test some web services. I have been using SOAPUI to test web services before and also SELENIUM to do some webUI testing. My current task involve testing some oauth services. Basically I need to be able to go through the oauth authentication using SELENIUM and store the access token produced and pass it along my SOAPUI test to test the services. I have read plenty of blogs talking about integrating selenium with SOAPUI but i haven't see and guide that shows you how to do it. I am using a MacbookPro with SOAPUI 4.0.1 Any help will be much appreciated.

like image 692
Assane Diop Avatar asked May 16 '26 21:05

Assane Diop


2 Answers

I could invoke Webdriver instance in SOAP Groovy Script and assert API's with UI assertions follow below steps

Step1 : Go to your SoapUI installation directory bin/ext and drop your selenium standalone server jar files (All jars in this path will be loaded to your path , You can add any jar files in this location and call them in Groovy script steps)

C:Program Files /SmartBearSoapUI-Pro-4.6.4/bin/ext

Jar file Name : selenium-server-standalone-2.40.0

Step 2 : Create a new Project in SOAP UI

Step 3: Add New Groovy Script step

Step 4: Create your selenium driver using below script in Groovy Step (Groovy is built on Java so all JAVA libraries and code would work as such)

import org.openqa.selenium.WebDriver 
import org.openqa.selenium.firefox.FirefoxDriver

    WebDriver driver = new FirefoxDriver(); 
    driver.get("http://www.google.com ") 
    log.info("Pagee is: " + driver.getTitle()) 
    driver.quit()

Step 5 : Run your script

  • You might have to restart your soapui session for the first time.

If you want to verify API's in JAVA Webdriver code I would suggest you to use REST assured API

https://code.google.com/p/rest-assured/

Hope this helps.

like image 60
Prasanth RJ Avatar answered May 18 '26 15:05

Prasanth RJ


First step, you need to download latest selenium-server-standalone-*.jar and place it in $SOAPUI_HOME/bin/ext; restart SoapUI.

Next you need to write your Selenium script as a Groovy script in a Groovy Step: no class declaration. So something like:

def chromeDriverBinary = new File("selenium/bin/windows/googlechrome/32bit/chromedriver.exe")
assert chromeDriverBinary.canExecute()
System.setProperty("webdriver.chrome.driver", chromeDriverBinary.canonicalPath)

def driver = new ChromeDriver()
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS)
driver.get("http://www.website.test")

This question still has no accepted answer, so I thought I would post my own attempt, described in a blog post: http://siking.wordpress.com/2011/08/22/groovy-selenium-webdriver-and-soapui-part-3/ Maybe it will be useful to someone?

like image 38
SiKing Avatar answered May 18 '26 15:05

SiKing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!