Forum Discussion

Josh_147's avatar
Josh_147
Contributor
5 years ago
Solved

How to detect title of dialog first then only decide which script to be executed? VBScript

Hi, I'm using TestComplete11 with VBScript. My situation is I have a desktop application which is RobotArm and it developed into 32bit and 64bit.

 

The RobotArm(x32) has the starting dialog named "MAIN PAGE" with button "SKIP", while RobotArm(x64) has the starting dialog named "Home" with button "Skip".


My scirpt can work well for both version but when the software is loading slow, the script will be executed and ignored the dialog when it came out after that.

 

Can TestComplete detect the dialog title first and then decide which line to be executed? As I know TestComplete execute the script line by line. I tried to use 'Select Case' method but it got error.

 

My purpose is the script can be applied for both x32 and x64 application. The vbscript is shown as below. Thanks for any suggestion.

 

sub InitialDialog

set w=sys.Process("RobotArm").WaitWindow("#32770", "MAIN PAGE",-1,1000)
set w1=sys.Process("RobotArm").WaitWindow("#32770", "Home",-1,1000)

if w.Exists then
   w.Window("Button", "SKIP", 1).Click
elseif w1.Exists then
   w1. Window("Button", "Skip", 1).Click
else
end if

end sub 

 

  • EVery process has a propery called ProcessType.  If it's 32 bit, this will have a value of x86, if it's 64 bit, this will have a value of x64.

     

    So, you could rewrite your code like this.

     

    sub InitialDialog
    
    set w=sys.Process("RobotArm").WaitWindow("#32770", "MAIN PAGE",-1,1000)
    set w1=sys.Process("RobotArm").WaitWindow("#32770", "Home",-1,1000)
    
    if Sys.Process("RobotArm").ProcessType = "x86" then
        w = Sys.Process("RobertArm").WaitWindow("#42770", MAIN PAGE", -1, 10000);
    
    else w = Sys.Process("RobertArm").WaitWindow("#32770", "Home", -1, 10000)
        w.Window("Button", "SKIP", 1).Click
    
    end if
    
    end sub 

     

    Side Note... investigate NameMapping.  You can identify objects a LOT easier and a LOT more reliably when they are mapped.  Your "Home" page could even be contingent mapping where the choices of how to identify it are built in so you don't even need to do the "WaitWindow".

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What you have is pretty good code for what you want.  However, your time out (currently set to 1000) may not be enough.  I'd bump that up to something like 10000 if your application takes longer than a second for the dialog to appear.

    • Josh_147's avatar
      Josh_147
      Contributor

      I had tried to increase the waiting time but if I applied the script on the 64bit application, I have to wait the 10 seconds to pass as the "HOME PAGE" won't appear. 

       

      Is there any method to avoid this? That can make the script more efficient. Thanks.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        EVery process has a propery called ProcessType.  If it's 32 bit, this will have a value of x86, if it's 64 bit, this will have a value of x64.

         

        So, you could rewrite your code like this.

         

        sub InitialDialog
        
        set w=sys.Process("RobotArm").WaitWindow("#32770", "MAIN PAGE",-1,1000)
        set w1=sys.Process("RobotArm").WaitWindow("#32770", "Home",-1,1000)
        
        if Sys.Process("RobotArm").ProcessType = "x86" then
            w = Sys.Process("RobertArm").WaitWindow("#42770", MAIN PAGE", -1, 10000);
        
        else w = Sys.Process("RobertArm").WaitWindow("#32770", "Home", -1, 10000)
            w.Window("Button", "SKIP", 1).Click
        
        end if
        
        end sub 

         

        Side Note... investigate NameMapping.  You can identify objects a LOT easier and a LOT more reliably when they are mapped.  Your "Home" page could even be contingent mapping where the choices of how to identify it are built in so you don't even need to do the "WaitWindow".