Wednesday, May 30, 2012

WScript to launch exe file


'WScript to launch  exe file
Set objApp = CreateObject("WScript.Shell")
objApp.run "C:\windows\system32\calc.exe"

Friday, May 25, 2012

Groovy : Read & Write values from csv file


//groovy script to store values in properties 

def testDataSet = []
def failureList = []
def fileName = "d:\\SOAPUI\\planets.CSV"

// Opens file, iterates through each line, splits the line on the commas into an array, and adds
// the array to testDataSet. (So testDataSet is an array of arrays).
new File(fileName).eachLine { line -> testDataSet.add( line.split(",") ) }

log.info( "Read " + testDataSet.size() + " test values from " + fileName )

// If any iteration fails, it will add an entry to the failure list, and they will all be printed at the end
context.setProperty( "failureList", failureList )

// Store the test data in a property called "testData"
context.setProperty( "testDataSet", testDataSet )


// This indicates which line of the file we will start reading from (0 = first line, 1 = second line, etc.)
// We are starting at the second line because the CSV contains a header row at the top that explains what
//   each column means
context.setProperty( "index", 1 )

//groovy script to read values from properties

def testDataSet = context.getProperty("testDataSet") // Retrieve the test data from the testData property
def index = context.getProperty("index") // Track which line of the test input file we're on
def testDataLine = testDataSet[index] // Select the current test data line

def props = testRunner.testCase.getTestStepByName( "Properties" )
props.setPropertyValue("AccountName", testDataLine[0])
props.setPropertyValue("AccountCode", testDataLine[1])
props.setPropertyValue("mars", testDataLine[2])

Practice Groovy

Groovy Examples

Thursday, May 24, 2012

Web Service Testing with SOAPUI

Groovy Script : Text File Create & Write.


def fileName = "test1.txt"
// Defining a file handler/pointer to handle the file.
def inputFile = new File("d:\\"+fileName)
// Check if a file with same name exisits in the folder.
if(inputFile.exists())
{
// if a file exisits then it will print the message to the log.
log.info("A file named " + fileName + " already exisits in the same folder")
}
else
{
//else it will create a file and write the text "Hello World !"

inputFile.write("Hello World !")
log.info "File got created"

}