Using Selenium in SoapUi
- Download
Selenium.jar
files from the following link, (http://www.seleniumhq.org/download/) - Download the Java language version of the Jars, once that is done a ZIP folder should be downloaded onto your PC.
- Unzip the Selenium – Java-'version no' folder.
- Open the unzipped folder.
- Copy the
selenium-java-2.52.0.jar
andselenium-java-2.52.0-srcs.jar
from the folder. - Open the SoapUI directory folder (In the previous chapter I opted for a default location, such as
C:\Project\SoapUI
. Refer to this location). - Place these jars in the following locations:
ext
folder andlib
folders - Once you have pasted the Jars in the
ext
folder you also need to paste them in thelib
folder of SoapUI as well. - 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 ");
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