We may face many intermittent issues,while validating rdp scripts.
We usually add rdp_sync_on_image on each and every page.But sometimes mouse clicks or synchronized mouse clicks may not work properly and hence the image check might fail.
Here is the simple logic for error handling
int imgchk,i;
char buffer[50];
i=0;do{
sprintf(buffer, "01_Transaction_%d",i);
lr_start_transaction(buffer);
//Perform a mouse click
rdp_mouse_click("StepDescription=Mouse Click",
"Snapshot=snapshot_87.inf",
"MouseX=50",
"MouseY=463",
"MouseButton=LEFT_BUTTON",
"Origin=Default",
RDP_LAST);
//imgchk returns "0" on success
imgchk = rdp_sync_on_image("StepDescription=Image Synchronization",
"WaitFor=Appear",
"AddOffsetToInput=Default",
IMAGEDATA,
"ImageLeft=215", "ImageTop=71", "ImageWidth=107", "ImageHeight=23", "ImageName=snapshot_88.png", ENDIMAGE,
RDP_LAST);
if (imgchk == 0)
{
lr_output_message("image check successful");
lr_set_transaction_status(LR_PASS);
lr_end_transaction(buffer,LR_AUTO);
}
//If image check fails, do one more click
else
{
i++;
lr_output_message("execute mouse click one more time and increment i val");
}
//Trying for a maximum of 3 times and then exiting the current iteration
if(i >= 2)
{
lr_output_message("Mouse click tried for 3 times and didn't work");
lr_exit(LR_EXIT_ITERATION_AND_CONTINUE,LR_FAIL);
}
}while(imgchk != 0 && i<=2);
We usually add rdp_sync_on_image on each and every page.But sometimes mouse clicks or synchronized mouse clicks may not work properly and hence the image check might fail.
Here is the simple logic for error handling
int imgchk,i;
char buffer[50];
i=0;do{
sprintf(buffer, "01_Transaction_%d",i);
lr_start_transaction(buffer);
//Perform a mouse click
rdp_mouse_click("StepDescription=Mouse Click",
"Snapshot=snapshot_87.inf",
"MouseX=50",
"MouseY=463",
"MouseButton=LEFT_BUTTON",
"Origin=Default",
RDP_LAST);
//imgchk returns "0" on success
imgchk = rdp_sync_on_image("StepDescription=Image Synchronization",
"WaitFor=Appear",
"AddOffsetToInput=Default",
IMAGEDATA,
"ImageLeft=215", "ImageTop=71", "ImageWidth=107", "ImageHeight=23", "ImageName=snapshot_88.png", ENDIMAGE,
RDP_LAST);
if (imgchk == 0)
{
lr_output_message("image check successful");
lr_set_transaction_status(LR_PASS);
lr_end_transaction(buffer,LR_AUTO);
}
//If image check fails, do one more click
else
{
i++;
lr_output_message("execute mouse click one more time and increment i val");
}
//Trying for a maximum of 3 times and then exiting the current iteration
if(i >= 2)
{
lr_output_message("Mouse click tried for 3 times and didn't work");
lr_exit(LR_EXIT_ITERATION_AND_CONTINUE,LR_FAIL);
}
}while(imgchk != 0 && i<=2);
Very usefull info
ReplyDeleteThanks Suma Very Useful info
ReplyDelete