Error Handling - Need help on this

I am getting a alert pop-up, need to click on 'OK' button on this and 'OK' button is working with space key of the keyboard. but below code won't work for me.


Try
If ImageFound(Text:"View12 and pay your bills", IgnoreNewLines:"Yes", ignoreSpaces:"No")
LogSuccess "Text on OnBoardingBillsDeatils_1_Page is correct"
else
LogError "Text on OnBoardingBillsDeatils_1_Page is incorrect"
end if
catch
TypeText space
end try

To go into the catch section the first code needs to have an exception thrown. Exceptions are thrown by trying to click an image/text that is not on the screen, or syntax errors, among others. LogError does not throw an error so Eggplant will not go into the catch code.

You can manually throw the exception
Try
If ImageFound(Text:“View12 and pay your bills”, IgnoreNewLines:“Yes”, ignoreSpaces:“No”)
LogSuccess “Text on OnBoardingBillsDeatils_1_Page is correct”
else
LogError “Text on OnBoardingBillsDeatils_1_Page is incorrect”
Throw “Incorrect page”, “Unable to find expected text”
end if
catch
TypeText space
end try

1 Like

Anne,

actually, I put the incorrect text message into the ImageFound(Text:“View12 and pay your bills”) so ill get the Alert (failed script) pop-up and trying to handle the error pop-up.

thanks your reply but still alert error pop-up not get handled in the script.

thanks

The easiest way to deal with alert popups would be to have another if statement. Something like:

If ImageFound(Text:"View12 and pay your bills", IgnoreNewLines:"Yes", ignoreSpaces:"No")
	LogSuccess "Text on OnBoardingBillsDeatils_1_Page is correct"
else
	LogError "Text on OnBoardingBillsDeatils_1_Page is incorrect"
end if

if imagefound("PopupError")
	logwarning "PopupError appeared"
	typetext space
end if

Let me know if I’m misunderstanding your workflow

Anne,

see the error message. I hope, it is eggplant error Alert pop-up, if it app error message then we can use the above code and handle it. but it looks something different. when i press space key of laptop. pop-up get disappear. or if i make changes in my code LogError to Log warning then ill will not see this popup but this is error and I cant change as log warning

error

thanks

Ah, I see. I misunderstood and thought the popup was in your application and not in Eggplant.

This popup will show up at the end of a test run if there is an exception thrown (eg. being unable to find an image or text in a click statement) or if there is a logerror. The script will continue until the end, at which case Eggplant shows this alert to notify you that there was an error.

If you want to turn this off, you can uncheck the Alert user when script execution fails on the General tab of the Eggplant Preferences screens.

1 Like

Anne Yes, it works for me.

thanks

Anne, if I want to handle in my code is there any ways to handle it. or just only this is the way to disable it. id don’t want to disable it.

thanks

LogError will not throw an exception so there is no need to handle it. Eggplant will just make a note that there was an error in the test and notify you at the end (if you have the setting turned on). It will not stop Eggplant from continuing through the rest of the script. You only need to handle exceptions using Try/Catch.

Exceptions are thrown when you are trying to do an action against something that is not on the screen, there is an error in your code, or you manually throw it.

http://docs.eggplantsoftware.com/ePF/SenseTalk/stk-error-handling.htm

Hi Anne,
Can help me to resolve the App-crash when launch the eggplant functional. i didn’t find any re-solution for this?
image

Problem signature:
Problem Event Name: APPCRASH
Application Name: Eggplant.exe
Application Version: 0.0.0.0
Application Timestamp: 5c6d952c
Fault Module Name: libobjc.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 58090348
Exception Code: c0000005
Exception Offset: 000000000000e279
OS Version: 6.3.9600.2.0.0.256.4
Locale ID: 2057
Additional Information 1: 95f0
Additional Information 2: 95f044efcad1053e478bec75ca84c754
Additional Information 3: 01f7
Additional Information 4: 01f787886c9ed149655980fe3d74dca5
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=280262

If the online privacy statement is not available, please read our privacy statement offline:
C:\windows\system32\en-GB\erofflps.txt

Can you send that to Support@eggplantsoftware.com? They can help troubleshoot a crash.

Thanks Anne, i found the solution.

Hi Anne,

how to read the text from the SUT screen and compare it if we would able to store in eggplant any how(expected result). if any discrepancy then let us know this text is mismatch in actual and expected results … how to do that in eggplant?

thanks

Sure, it should be pretty simple. Something like:

put "String to compare to" into compareString

//Get string from SUT
put readtext ("TopLeftImage", "BottomRightImage") into ReadString 
(*//Or you can use the SUT's Clipbaord 
//Highlight area 
Drag "StartPointIMG"
Drop "StopPointIMG"
SetRemoteClipboard ""
Typetext controlkey, "c"
put RemoteClipboard() into Readstring*)
if ReadString is not equal to compareString
	logwarning <<Read String is different. Was expecting ">> & compareString & <<" Instead got ">> & ReadString & <<">>
end if

scenarios 1:
thanks Anne for clarification, if we compare the string from SUT as below, i feel it could be device specific when put readtext (“TopLeftImage”, “BottomRightImage”) into ReadString
Please correct me if i am wrong
//Get string from SUT
put readtext (“TopLeftImage”, “BottomRightImage”) into ReadString
scenarios 2:
One more query: how to handle the situation, if data response fetch from the API and and get delay into response or failed. so our test script should not get stop or failed in this situation. how to handle this situation.
comeback on home screen after sometime or start a new test cases execution and display some warning. Please correct me if i am wrong

scenarios 1:
thanks Anne for clarification, if we compare the string from SUT as below, i feel it could be device specific when put readtext (“TopLeftImage”, “BottomRightImage”) into ReadString
Please correct me if i am wrong
//Get string from SUT
put readtext (“TopLeftImage”, “BottomRightImage”) into ReadString

scenarios 2:
One more query: how to handle the situation, if data response fetch from the API and and get delay into response or failed. so our test script should not get stop or failed in this situation. how to handle this situation.
comeback on home screen after sometime or start a new test cases execution and display some warning. Please correct me if i am wrong

Scenario 1:
This search rectangle shouldn’t be device specific, Eggplant will look for the images on the screen so they can shift depending on the device. If the images look different on different devices you can use image collections or the adaptive search type. If you are concerned about the images being different, you can also try using OCR ie:

put readtext((text:"start string"), (text:"End string"))

or even just using OCR for one part of the searchrectangle and hard coding offsets.

put imagelocation(text:"Start Text", hotspot:(0,0)) into TL

put readtext(TL, TL+(300,50))

//or Use the SUT screen size
put readtext(TL, TL+(RemoteScreenSize().width, 50))

Scenario 2:
This easily doable. You can use our API module to get the API response and use that to compare the text:

Example API test:

APIGet
put the result into StringtoCompare //to get the returned value you need to use the Eggplant Global Property the result

put readtext(TL, BR) into ReadString

if ReadString is not equal to StringtoCompare
	logwarning <<Read String is different. Was expecting ">> & StringtoCompare & <<" Instead got ">> & ReadString & <<">>
end if

Hi Anne,

I’m trying to understand how the try/catch function is working : I would like the code to go to the “catch” statement when an image is not found but without using the “throw” command. However, it seems that the execution is stopped even if the error happens in the try section. Is there any way to do this ? I would like to continue with the next scripts if one cannot be executed completely.

My code looks like this :

Try
    Click "ETM_review/Action"
Catch
    LogError "An error occured while executing the script" & my name
End Try

Dorian