Saturday, September 17, 2016

SOAPUI : Using Selenium in SoapUi

Using Selenium in SoapUi


  1. Download Selenium.jar files from the following link,  (http://www.seleniumhq.org/download/)
  2. Download the Java language version of the Jars, once that is done a ZIP folder should be downloaded onto your PC.
  3. Unzip the Selenium – Java-'version no' folder.
  4. Open the unzipped folder.
  5. Copy the selenium-java-2.52.0.jar and selenium-java-2.52.0-srcs.jar from the folder.
  6. Open the SoapUI directory folder (In the previous chapter I opted for a default location, such as C:\Project\SoapUI. Refer to this location).
  7. Place these jars in the following locations: ext folder and lib folders
  8.  Once you have pasted the Jars in the ext folder you also need to paste them in the lib folder of SoapUI as well.
  9. After this step we are done with the setup we now need to work on the Groovy script.
    Following is sample Groovy script for invoking a UI from SoapUI using Groovy script enabled by Selenium Jars:

    import com.eviware.soapui.model.*
    import com.eviware.soapui.model.testsuite.Assertable
    import com.eviware.soapui.support.XmlHolder
    import java.io.File;
     
     def regLogger = org.apache.log4j.Logger.getLogger("RegressionTestLoger");
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def properties = new java.util.Properties();
     
     import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import com.thoughtworks.selenium.Selenium;
    
    WebDriver driver = new FirefoxDriver();
    driver.manage().deleteAllCookies();
    driver.manage().window().maximize();
      WebDriver driver = new FirefoxDriver();  
      driver.get("http://www.google.com ");
     
     
    sample script for UI automation using the Chrome driver:
    Chrome:
    you need to install the Chrome driver and set the path of the chrome driver in the path of the system or uncomment  "System.setProperty" from the code below:
     
    import org.openqa.selenium.*;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    import com.eviware.soapui.model.*
    import org.openqa.selenium.chrome.ChromeDriver;
    import com.eviware.soapui.model.testsuite.Assertable
    import com.eviware.soapui.support.XmlHolder
    import java.io.File;
    //import java.util.*;
    //import jxl.write.*
    //import jxl.*
    def regLogger = org.apache.log4j.Logger.getLogger("RegressionTestLoger");
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    def properties = new java.util.Properties();
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import com.thoughtworks.selenium.Selenium;
    
    //System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\SmartBear\\SoapUI-5.0.0\\bin\\ext\\chromedriver.exe");
    //WebDriver driver = new ChromeDriver();
                         driver.manage().deleteAllCookies();
     driver.get("http://www.google.com ");
     
     
 

No comments:

Post a Comment