Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
6 years ago

TestComplete mobile noob on Android

I have been able to instrument and deploy my mobile app (Cordova) to my device. I am able to run the app with TestComplete. I tried to record a script to login. This was recorded:

 

 

function Test2()
{
  Mobile.SetCurrent("Pixel");
  Aliases.Device.Process_obfuscated_new.RootLayout.Layout_NO_ID.WebView_comObfuscatedMobileAppKeypadHandler.Page_androidassetwwwdefaultindex.Wait();
}

I ran it for fun despite looking like it does not do anything. Indeed, it does not do anything.

 

 

I looked in the object spy to point to the user name. I can only point to

 

Aliases.Device.Process_obfuscated_new.RootLayout.Layout_NO_ID.WebView_comObfuscatedeMobileAppKeypadHandler

 

The red highlight is around the entire app window.

 

How do I get TestComplete to "see" objects within this window? Thanks

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    One more thing I would recommend to try is to use not obfuscated build of the tested application.

    (Yes, I agree that those will be two different applications and additional (manual) testing for the obfuscated application must be done to ensure that application does not crash after been obfuscated with the given obfuscation settings. The good news is that no functional testing is usually needed in this case. Just a quick verification that application does not crash, shortcuts are working, text is displayed as expected, etc.)

     

    • vthomeschoolmom's avatar
      vthomeschoolmom
      Super Contributor

      Ok, I was given the instrumented app by someone else who cannot remember how it was done. I had read through the tutorial but skipped that part thinking it was done properly. I am not sure given this sentence in the instrumentation documentation.

       

      " However, in this case, you will be able to create only image-based tests. " 

       

      I will redo this. Thanks for your help.

       

      S

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        I was given the instrumented app by someone else who cannot remember how it was done.

        Note, that application must be instrumented using the same version of TestComplete that will be used to run the test.

         

        P.S. Sample code to check instrumentation:

        //-----------------------------------------------------------------------------
        
        // From: http://blog.falafel.com/instrumenting-android-apps-ii/
        // From: http://blog.falafel.com/instrumenting-android-apps-iii/
        function AppInstrumentationVerify(strAppName : string; bStopTestRun : OleVariant = true) : OleVariant;
          var app : OleVariant;
          var boolResult : OleVariant;
          var strMsg : string;
        begin
          app := evaluate(aqString.Format('TestedApps.%s;', strAppName));
          if (not app.Instrumented) then
          begin
            app.UseCustomCertificate := false;
            app.BackupOriginalAPK := true;
            boolResult := app.Instrument();
            if (boolResult) then
              Log.Message(aqString.Format(
                  '%s tested application has not been instrumented so TestComplete did this to get access to its internals',
                  aqString.Quote(strAppName)), strAppName)
            else
              Log.Warning(aqString.Format(
                  'TestComplete failed to instrument the %s tested application',
                  aqString.Quote(strAppName)), strAppName);
          end;
        
          boolResult := app.InstrumentedWithSupportedVersion;
          if (not boolResult) then
          begin
            if (bStopTestRun) then
              strMsg := ' Test run stopped.'
            else
              strMsg := '';
            Log.Warning(aqString.Format(
                '%s instrumentation is NOT compatible with TestComplete v.%i.%i.%s',
                app.APKFileName, getRunningTCMajorVersion(), getRunningTCMinorVersion(), strMsg), app.APKFileName);
            if (bStopTestRun) then
              Runner.Stop(false);
          end;
        
          result := boolResult;
        end;
        //-----------------------------------------------------------------------------