Automation Testing - Click Here
Welcome to Hemanth's Blog
Saturday, December 4, 2021
Tuesday, April 28, 2020
SOAP UI - Read Excel data using Groovy Code
How to read the data in excel using Groovy script in SOAP UI Free Version tool
To Read the data from excel sheet we need to download the "jxl-2.6.jar", any latest version can work
and place the jar in the location where SOAP UI in "ext" folder under "bin" (.\\SmartBear\SoapUI-5.5.0\bin\ext)
Groovy code for reading the Excel data - "save the excel file as *.xls file format"
// IMPORT THE LIBRARIES WE NEED
import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*
// DECLARE THE VARIABLES
def myTestCase = context.testCase //myTestCase contains the test case
def counter,next,previous,size //Variables used to handle the loop and to move inside the file
def ProjectPath = new com.eviware.soapui.support.GroovyUtils(context).projectPath+"/OnboardingsInput.xls" //(Give the required file name - Sample.xls)
log.info(ProjectPath)
Workbook workbook1 = Workbook.getWorkbook(new File(ProjectPath)) //file containing the data
Sheet sheet1 = workbook1.getSheet("ProfileController") // ( WorkBook - Sheet name should be specified)
size= sheet1.getRows().toInteger() //get the number of rows, each row is a data set
propTestStep = myTestCase.getTestStepByName("ExcelProperties") // (Give the Name as Created for the Properties file - created in the TestSuite(TS) by Right Click on TS and Select the Properties file)
propTestStep.setPropertyValue("Total", size.toString())
counter = propTestStep.getPropertyValue("Count").toString() //counter variable contains iteration number
counter = counter.toInteger()
log.info(counter)
// OBTAINING THE DATA YOU NEED
// Code to read an single data
Cell m1 = sheet1.getCell(12,1)
CandidateID = m1.getContents()
propTestStep.setPropertyValue("CandidateID", CandidateID) //the value is saved in the property
//To get Complete column values
for(i=1;i<size;i++)
{
def G=sheet1.getCell(6,i).getContents()
propTestStep.setPropertyValue("ResponseCode"+i,G)
}
//Decide if the test has to be run again or not
if (counter == size-1)
{
propTestStep.setPropertyValue("StopVal", "T")
log.info "Setting the StopVal property now..."
}
else if (counter==0)
{
def runner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null)
propTestStep.setPropertyValue("StopVal", "F")
}
else
{
propTestStep.setPropertyValue("StopVal", "F")
}
// To read and access the Values , create an "Excel Property" file in the Test Suite and create the Key and values of 3 variables
1. Count - 1
2. StopVal - F
3. Total - once executed automatically the value will be generated.
Saturday, August 12, 2017
How to Remove the Error in Maveen Project "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment."
To resolve this issue, please do the following steps,
- Right click on the Maveen Project.
- Choose "Build path" in the Menu.
- Choose "Configure Build path".
- Choose "Libraries tab".
- Select "JRE System Library" and click on "Edit: button.
- Choose "workspace default JRE" and click "Finish".
Wednesday, June 22, 2016
Program : 22
#include<stdio.h>
#include<conio.h>
struct slinklist
{
int data;
struct slinklist *next;
};
typedef struct slinklist node;
node *start=NULL;
void createlist(int);
void insert_node_at_begin();
Publish Post
void insert_node_at_mid();
void insert_node_at_end();
void delete_node_at_begin();
void delete_node_at_mid();
void delete_node_at_end();
void display_left_to_right();
void display_right_to_left(node*);
node *getnode();
int countnode(node*);
int menu();
void main()
{
int ch,n=5;
clrscr();
do
{
ch=menu();
switch(ch)
{
case 1:createlist(n);
break;
case 2:insert_node_at_begin();
break;
case 3:insert_node_at_mid();
break;
case 4:insert_node_at_end();
break;
case 5:delete_node_at_begin();
break;
case 6:delete_node_at_mid();
break;
case 7:delete_node_at_end();
break;
case 8:display_left_to_right();
break;
case 9:display_right_to_left(start);
break;
case 10:exit(1);
default:printf("wrong choice");
break;
}
}while(1);
getch();
}
int menu()
{
int ch;
printf("menu\n");
printf("1.create list \n");
printf("2.insert node at begin\n");
printf("3.insert node at mid\n");
printf("4.insert node at end\n");
printf("5.delete node at begin\n");
printf("6.delete node at mid\n");
printf("7.delete node at end\n");
printf("8.display list from left to right\n");
printf("9.display list from right to left\n");
printf("10.exit\n");
printf("enter your choice");
scanf("%d",&ch);
return(ch);
}
void createlist(int n)
{
int i;
node *newnode,*temp;
for(i=0;i<n;i++)
{
newnode=getnode();
if(start==NULL)
{
start=newnode;
}
else
{
temp=start;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=newnode;
}
}
}
void insert_node_at_begin()
{
node *newnode;
newnode=getnode();
if(start==NULL)
{
start=newnode;
}
else
{
newnode->next=start;
start=newnode;
}
}
void insert_node_at_mid()
{
node *newnode,*post,*prev;
int ctr=1,p,count;
newnode=getnode();
if(start==NULL)
{
start=newnode;
}
else
{
printf("enter the position");
scanf("%d",&p);
count=countnode(start);
if(p>1&&p<count)
{
prev=start;
post=start;
while(ctr<p)
{
prev=post;
post=post->next;
ctr++;
}
prev->next=newnode;
newnode->next=post;
}
else
printf("invalid choice");
}
}
void insert_node_at_end()
{
node *newnode,*temp;
newnode=getnode();
if(start==NULL)
start=newnode;
else
{
temp=start;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=newnode;
}
}
void delete_node_at_begin()
{
node *temp;
if(start==NULL)
printf("list is empty");
else
{
temp=start;
start=start->next;
free(temp);
printf("element is deleted");
}
}
void delete_node_at_mid()
{
node *temp,*prev;
int ctr=1,p,count=0;
if(start==NULL)
printf("list is empty");
else
{
printf("enter position");
scanf("%d",&p);
count=countnode(start);
if(p>1&&p<count)
{
prev=start;
temp=start;
while(ctr<p)
{
prev=temp;
temp=temp->next;
ctr++;
}
prev->next=temp->next;
free(temp);
}
else
printf("invalid choice");
}
}
void delete_node_at_end()
{
node *temp,*prev;
if(start==NULL)
printf("list is empty");
else
{
temp=start;
prev=start;
while(temp->next!=NULL)
{
prev=temp;
temp=temp->next;
}
prev->next=NULL;
free(temp);
}
}
void display_left_to_right()
{
node *temp;
if(start==NULL)
{
printf("list is empty");
}
else
{
temp=start;
while(temp!=NULL)
{
printf("%d",temp->data);
temp=temp->next;
}
}
}
void display_right_to_left(node *st)
{
if(st==NULL)
return 0;
else
{
display_right_to_left(st->next);
printf("%d",st->data);
}
}
int countnode(node *st)
{
int count=0;
node *temp;
if(st==NULL)
return 0;
else
return(1+countnode(st->next));
}
node *getnode()
{
node *newnode;
newnode=(node*)malloc(sizeof(node));
printf("enter data");
scanf("%d",&newnode->data);
newnode->next=NULL;
return(newnode);
}
Wednesday, February 26, 2014
Misc Programs
Deleting the Duplicates from an array
#include<stdio.h>
#include<conio.h>
void main()
{
int n, a[10], b[10], count = 0, i, j;
clrscr();
printf("Enter the Range :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter a[%d]",i);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<count;j++)
{
if(a[i]==b[j])
break;
}
if(j==count)
{
b[count] = a[i];
count++;
}
}
printf("Array obtained after removing duplicate elements\n");
for(i=0;i<count;i++)
printf("%d\n",b[i]);
getch();
}
#include<conio.h>
void main()
{
int n, a[10], b[10], count = 0, i, j;
clrscr();
printf("Enter the Range :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter a[%d]",i);
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<count;j++)
{
if(a[i]==b[j])
break;
}
if(j==count)
{
b[count] = a[i];
count++;
}
}
printf("Array obtained after removing duplicate elements\n");
for(i=0;i<count;i++)
printf("%d\n",b[i]);
getch();
}
Finding the Kth largest Element in an array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20];
int num,k,i,c;
clrscr();
printf("Enter number of elements\n");
scanf("%d",&num);
printf("Enter elements\n");
for(i=0;i<num;i++)
{
printf("Enter a[%d] = ",i);
scanf("%d",&a[i]);
}
printf("Enter k\n");
scanf("%d",&k);
c=1;
for(i=1;i<num;i++)
{
if(c==k)
{
printf("kth Smallest with k=%d is %d",k,a[i-1]);
break;
}
if(a[i]!=a[i-1])
c++;
}
getch();
}
#include<conio.h>
void main()
{
int a[20];
int num,k,i,c;
clrscr();
printf("Enter number of elements\n");
scanf("%d",&num);
printf("Enter elements\n");
for(i=0;i<num;i++)
{
printf("Enter a[%d] = ",i);
scanf("%d",&a[i]);
}
printf("Enter k\n");
scanf("%d",&k);
c=1;
for(i=1;i<num;i++)
{
if(c==k)
{
printf("kth Smallest with k=%d is %d",k,a[i-1]);
break;
}
if(a[i]!=a[i-1])
c++;
}
getch();
}
Subscribe to:
Posts (Atom)