Forum Discussion

anhvu's avatar
anhvu
Frequent Contributor
10 years ago

Why TestComplete Stops running when an property is not found or null.

Hi All,

 

I am suffered the "Unspecified Error" from TestComplete when running the script overnight.

 

When the device was not recognized by TestComplete/TestExecute, it will throw the "Unspecified Error" error and stop working.  (The device is still able to be recognized by ADB)

 

Is there any way to prevent this error or let testcomplete continue to the next command without

 

Example:

while(aqDateTime["Now"]()<endtime)
{

Mobile["Refresh"]()
if(Mobile["Device"](device)["Exists"]==true)
{

Mobile["Refresh"]()
if(Mobile["Device"](device)["Process"]("com.HBO")["Exists"] == true)
{
var pHBO1 = Mobile["Device"](device)["Process"]("com.HBO")

var time3 = aqString["Trim"](pHBO1["RootLayout"]("")["Layout"]("content")["Layout"]("videoLayout")["Layout"]("NO_ID")["Layout"]("root_layout")["Layout"]("playercontrols")["Layout"]("controllayout")["Layout"]("seekbar_time_layout")["TextView"]("starttime")["getText"]())
Delay(4000)
var time4 = aqString["Trim"](pHBO1["RootLayout"]("")["Layout"]("content")["Layout"]("videoLayout")["Layout"]("NO_ID")["Layout"]("root_layout")["Layout"]("playercontrols")["Layout"]("controllayout")["Layout"]("seekbar_time_layout")["TextView"]("starttime")["getText"]())
if(time3 == time4)
{
Log["Error"]("THE VIDEOS IS NOT PLAYING! RESTART THE MOVIE")
...........
}
ele
{
Log["Message"]("The Video is still playing.")
}
}

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1

    Hi,

     

    Try to use the TryToSetCurrent() method. I.e. instead of

    Mobile["Refresh"]()
    if(Mobile["Device"](device)["Exists"]==true)

    use

    if(Mobile["TryToSetCurrent"](device))

    ...

    and move

    Mobile["Refresh"]()

    to the end of the

    while(aqDateTime["Now"]()<endtime)

    loop in order not to do unnecessary refresh if the device is already found.

     

    Does it help?

    • anhvu's avatar
      anhvu
      Frequent Contributor

      Hi Alexkaras,

       

      Thank you for your suggestion but it didn't help. It happened because sometimes testcomplete doesn't recognize the device.

       

      I just update my script and it works as expected.

       

      adding: check the property is empty or null, if null I will refesh the usb port and check it again.

       

      So far, it works for me.

      • AlexKaras's avatar
        AlexKaras
        Icon for Champion Level 1 rankChampion Level 1

        Hi,

         

        Thank you for the update.

        Yes, for some reason TestComplete (or adb?) sometimes loses connection to the device.

         

        > [...] if null I will refesh the usb port and check it again.

        Just wondering if you do this programmatically within your test code or just manually reconnect the device?