Forum Discussion

NikitaPyatakov's avatar
NikitaPyatakov
Occasional Contributor
4 years ago

Testcomplete not "see" object of Android app in "Object Browser" after "adb shell am force-stop"

Hi All!

 

I ran into the following problem:

If I run the "adb shell am force-stop <PACKAGE>" command while the script is running and run the Android app again with the "am start-n yourpackagename/.activityname" command, then the app is no longer visible in the "Object Browser" tab.

 

Two points are also known:
1. the command " ... am force-stop .. "stops all child processes associated with the running package, which means that "your "(with the prefix". tctest") application also stops working

2. When I start the application via "TestComplete", then " TestComplete":
2.1 repackages "my" app in " packege.name-signed. apk"
2.2 creates an additional application "instrumentation-signed. apk" ("your")
2.3 installs these two apps on the device while removing the two apps from the computer at the same time
2.4 somehow runs both apps, so that "my" re-packaged app will run through " yours"

 

So I have questions:

1. What is the best way to stop the app so that the connection between "my" re-packaged app and "your" app is not lost?

2. If I have "my" repackaged application and "your" application, in what order and with what commands do I need to launch the applications so that after launching "my" repackaged application, the objects are visible on the "Object Browser" tab?

 

P.S.

Suggestion:
make a human work with the tested Android application from the "TestedApp" module-give opportunities:
1. Launch the app (with a full cycle of operation)
2. Run only the app (without instrumentation, just run and that's it)
3. Deploy the app (with a full cycle of operation) without starting
4. Deploy only (without instrumentation, just deploy and that's it)
5. Stop the app (just stop and that's it)
6. Restart the app (just restart and that's it)
7. Delete the app (just delete and that's it)


Let this functionality be available only from the script.

 

P.P.S.

My env:

PC: Win10x64, ru

Android Studio: 4.0.1 x64

TestComplete: 14.71 x64

 

Thanks!

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    @AlexKaras  @Marsha_R , do you have any ideas?

    I will check with the current 14.71 version of TestComplete and let you know the result.

    What worked for me previously:

    -- '... am force-stop ...' to stop application;

    -- PackManagerObj.RemovePackage(PackObj, False); to remove the package;

    -- PackManagerObj.InstallPackage(PackObj, true); to install the package;

    -- http://blog.falafel.com/instrumenting-android-apps-ii/, http://blog.falafel.com/instrumenting-android-apps-iii/ to check if the application was properly instrumented;

    -- '... am start -n <process>/<activity>' or PackManagerObj.LaunchPackage(PackObj); to start application;

    -- app.Instrument(); to (re-)instrument tested application.

     

    • C-Hansen's avatar
      C-Hansen
      Occasional Contributor

      Hi everyone,

       

      Have you figured out a solution to this problem or have you heard from Smartbear, because I was thinking about opening a support ticket about this issue.

       

      There is definitely something that has changed, with the new way instrumentation works in 14.70 and 14.71. At least I didn't have the issue on 14.61 and before that.

       

      We have used the adb force-stop command for a long time followed by LaunchPackage method without any issues, but now we have noticed the same thing as described by OP. After a force-stop the only way of getting TestComplete to notice the objects again seems to be to reinstall the app. Not even manually opening the app on the phone works.

       

      However I've also seen the issue without actively doing a force-stop command. Before I could instrument the app and it would just work. I could go a whole work day debugging and testing on that app. However now I notice that I often need to reinstall the app because TestComplete can't see the objects. I'm not sure when it happens, might be after a crash of the app, the system killing the app by itself or something else. After it happens there seem to be no way of launching the app again without a reinstall.

       

      Thanks.

       

      • NikitaPyatakov's avatar
        NikitaPyatakov
        Occasional Contributor

        2 C-Hansen

         

        adb force-stop command - this command kills the process itself and all its child processes - that's why we don't see objects

         

        This is because your application is called through the TestComplete agent on the device while running the application with the prefix ". tctest" as a child process of your main application

         

        Kulibins...