Ask a Question

Handling Inconsistent popups

SOLVED
jaredjamieson
Occasional Contributor

Handling Inconsistent popups

I am writing a script test that performs a login using Apple ID.  In the app the user selects 'login with Apple Id' then they are brought to Apple's login browser which pops up over the app.  This is all expected. 

 

The issue is that sometimes This browser does not load and a system notification is shown stating 'The app did not load correctly'.  This is an Android specific popup that was not implemented by my tested app. 

 

I am able to incorporate logic that if this popup is on screen then it will click 'continue' and go about as expected.  My issue is when this popup does not occur, my script will present an error saying the popup is not found then continue with the logic as expected.  I am using the .Visible, .VisibleOnScreen, and .Exists attributes but they still all run causing the attached error.  

 

I can see in the logs that either way the script continues and in the end will output correctly.  But since sometimes the popup does not occur, the if check is ran and produces an error causing the executed script to error.  Is there any way to handle a sometimes occurring element without producing any errors in the logs?  

4 REPLIES 4
AlexKaras
Community Hero

Hi,

 

Can you provide relevant piece of code that errors out?

I hope that I know the reason, but would like to double-check.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
jaredjamieson
Occasional Contributor

app = Aliases.Device.my_app_name;

 

if (app.FindElementById("android:id/aerr_close").Exists)
{
      app.FindElementById("android:id/aerr_close").Touch();
}

 

Remember, I have also tried .Visible and VisibleOnScreen properties.

 

Logs:

 

Hm-m-m... Weird...

Your code seems to be correct and I would expect it to work as expected as per https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/mobile/findelementbyi....

 

What I would try is to change your code to:

app = Aliases.Device.my_app_name;

 

errObj = app.FindElementById("android:id/aerr_close");

if (errObj.Exists)
{
      errObj.Touch();
}

 

and check in debugger if errObj is indeed a stub object with .Exists property available and whether or not the error is posted to test log if the sought for popup does not exist and report an issue to Support via the https://support.smartbear.com/testcomplete/message/ form if either non-stub object is returned when sought for object is not found or if an error is posed to test log in this case.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
jaredjamieson
Occasional Contributor

if (obj.Wait().Exists)

{

  // Some code

}

 

I found this in the documentation listed below.  The difference with this and the example you showed is the Wait element instead of the Find element!  Thank you for your help Alex.


https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/checking-existence.html

cancel
Showing results for 
Search instead for 
Did you mean: