Groovy

Groovy: SoapUI: SoapUiXShell.groovy

package com.gemalto.mcx.groovy

/**
 *
 * @author lroberts
 */
class SoapUiXShell {
        def log
        def testRunner
    
    def SoapUiXShell(){
        
    }
        
    
        def SoapUiXShell(log, testRunner){
        this.log = log
        this.testRunner = testRunner
    }
    
    def XShell_Open(){

            def command
            def proc
            def path_xshell = "T:\\TestFramework\\XshellPortable\\XshellPortable.exe"
            def path_xshell_session = "T:\\TestFramework\\doc\\XShellSession.xsh"
        
//            def command = """${path_xshell} ${path_xshell_session}"""
 //           def proc = command.execute()
  //          proc.waitFor()            
            
            //command = """${path_xshell} -newwin ${path_xshell_session}"""
            //command = "${path_xshell} -newwin ${path_xshell_session}"
            command = """${path_xshell}"""
            proc = command.execute()
            Thread.sleep(15000)
            log.info("XS
Tags

Groovy: SoapUI: SoapUiTools.groovy

package com.gemalto.mcx.groovy

import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.util.Date

class SoapUiTools {

    def log
    def testRunner
    
    def SoapUiTools(log, testRunner){
        //pass testRunner and Log to assign properties
        this.log = log
        this.testRunner = testRunner
    }
    
    def Logging(log){
        this.log = log
        log.info("Is it working?")
                
    }
    
    def Log_TestStep_Messages(){
        def filePath = testRunner.testCase.testSuite.project.getPropertyValue("pathLogs")

//        def startDate = new Date()
//        thisDate = startDate.format("yyyy_MMdd'_'HHmmss_SSS")
        //log.info filePath + thisDate
        
        def thisDate = new Date().format("yyyy_MMdd'_'HHmmss_SSS")
        log.info testRunner.testStepResult.testStep.label
    
        fos = new FileOutputStream( filePath + thisDate + "-step-" +  testRunner
Tags

Groovy: SoapUI: SoapUiExcel.groovy

package com.gemalto.mcx.groovy

import jxl.*
import jxl.write.*

import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.util.Date

import org.apache.poi.hssf.usermodel.HSSFCell
import org.apache.poi.hssf.usermodel.HSSFRow
import org.apache.poi.hssf.usermodel.HSSFSheet
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.HSSFCellStyle
import org.apache.poi.hssf.usermodel.HSSFDataFormat
import org.apache.poi.hssf.usermodel.*


class SoapUiExcel {
    
    def log
    def testRunner
        
    public SoapUiExcel(){
        
    }
    
    public SoapUiExcel(log, testRunner) {
        this.log = log
        this.testRunner = testRunner
    }
        
       
    /*
     * Read an Excel worksheet and get the Project Name
     * Row8,CellB
     */
    def Excel_ProjectName_Reader(pathExcelRunner){
        log.info "In Excel_ProjectName_Reader()"
        log.info "Open
Tags

Groovy: SoapUI: SoapUiAdb.groovy

package com.gemalto.mcx.groovy

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.support.ui.ExpectedCondition
import org.openqa.selenium.support.ui.WebDriverWait
import org.openqa.selenium.Dimension
import org.openqa.selenium.Point

class SoapUiAdb {

    def log
    def testRunner
    WebDriver testBrowser
    WebElement element
    //def adbexe = "T:\\TestFramework\\EclipseADT\\sdk\\platform-tools\\adb.exe"
    def adbexe          = testRunner.testCase.testSuite.project.getPropertyValue("pathAdbExe")
    def UrlQrCodeGen    = testRunner.testCase.testSuite.project.getPropertyValue("UrlQrCodeGen")

    /*
     * Constructor
     */
    def SoapUiAdb(log, testRunner){
        this.log = log
        this.testRunner = testRunner
        log.info "In SoapUiAdb()"
        log.info adbexe
    }

    def Get
Tags

Groovy: SoapUI: SoapUiSelenium.groovy

package com.gemalto.mcx.groovy

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver

import org.openqa.selenium.WebElement
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.support.ui.ExpectedCondition
import org.openqa.selenium.support.ui.WebDriverWait
import org.openqa.selenium.Dimension
import org.openqa.selenium.Point

//For ScreenCap
import java.io.File
import org.apache.commons.io.FileUtils
import org.openqa.selenium.TakesScreenshot
import org.openqa.selenium.OutputType
import java.util.concurrent.TimeUnit

class SoapUiSelenium {

    /*
     *  Calls to this CLASS MUST pass the *log* and *testRunner* objects
     *   log: used for sending log info to SoapUI
     *   testRunner: provides hooks for Test Case/Suite/Project/Environment Properties
     *     along with anything that is accessible by using the 'Groovy Script' Test Step
     *     directly within SoapUI
     */     
    def
Tags

Groovy: SoapUI: SoapUiRunner.groovy

package com.gemalto.mcx.groovy

/**
 *
 * @author Lance Roberts
 */
class SoapUiRunner {
        def log
        def testRunner

     /*
     * Constructor:
     * For internal calls
     */    
     def SoapUiRunner(){
     }
     
    /*
     * Constructor:
     * For internal calls
    */    
    def SoapUiRunner(log, testRunner){
        this.log = log
        this.testRunner = testRunner
        
        

    }

    def TestSuite_List_GetAndRun(pathExcelRunner){
        log.info "In TestSuite_List_Get()"
        //def testRunner2 = testRunner
        // Read from Excel workbook and make a list of tests to run
        //
        //def pathExcelRunner = "T://TestFramework//doc//TestRunner1.xls"

        def excel = new SoapUiExcel(log, testRunner)
        def thisProjectName = excel.Excel_ProjectName_Reader(pathExcelRunner)
        def testSuiteList = excel.Excel_TestSuite_Reader(pathExcelRunner)
        TestSuite_List_Run(thisProjectName, testSuiteList)
        }     
    
 
Tags

SoapUI: Groovy Scripts: CSV

SOAPUI Groovy Scripts: CSV

Groovy Script in SOAPUI allow for reaching out to external data and return reporting elements and data

  • Open Flie/DB connection
  • Read from CSV
  • Re-Name Test Steps from Excel Columns
  • Get Values from file for test step(s) values
  • Use variables/properties for
    • logging
    • Renaming Test Cases on-the-fly
    • Populating Request Messages
    • Populating Response Messages
    • Resetting Test Case to default values
  • Closing Flies/DB connections

Script Logging

log.info( "NEXT: : " + curTC.getPropertyValue("Symbol") )
log.info( "Test Case TearDown.." )

 

TestSuite

SetupScript

log.info(runner.getTestSuite().toString())
log.info(runner.toString())

 

Tags
Subscribe to Groovy