Forum Discussion

slecault's avatar
slecault
Contributor
3 years ago

FindElementbyXpath times out and TC ends in error - object not found

I run a mobile app on physical Android device connected (via usb) to my laptop using a local Appium server.

 

At one point (after executing a few interactions with the mobile app), I try to find an element by xpath.  The element is not on screen at the time of the search. I was expecting the findElementByxPath to return an empty object with the .Exists property. It is not the case and the tests stops with the message:

"Unable to find an element that matches the specified 'xpath' selector strategy and value '//*[contains(@text, "Professionnal")]"

 

My next step was to swipe up the screen if the object.Exists returns false.

 

Any suggestions as to why ".FindElementByXPath('//*[contains(@text, "' + findThisText + '")]');" makes the tests to stop instead of returning an empty stub (empty object with .Exists property)?

 

 

The same find by xpath works ok for a string which is on screen at the time of the search.

I am running TC 15.40

Android 9.1.0 on Huawei P20

 

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I would create Support ticket via the https://support.smartbear.com/testcomplete/message/ form.

    Documentation for the "FindElementByXPath Method (Mobile Objects)" clearly states that "

    If no matching object was found, the method will return a stub object. To determine whether the method returns a valid object, use the Exists property of the returned object. If the property returns False, the object is a stub object.". So your description sounds like a possible problem.

     

    • slecault's avatar
      slecault
      Contributor

      Thank you Alex, I have tried a "work arround" and "WaitElementByXpath" does return the expected EmptyObject with .Exists set to false.  I will use this method instead.

      In order to help others via documentation, I will also open a ticket.