Forum Discussion

eykxas's avatar
eykxas
Regular Contributor
9 months ago

Best way to test multi NameMapping

Hi everyone !

 

I have an annoying situation. My application has certain secure functions, which require a pin code.

 

The window offering to enter this pin code is not always handled in the same way. There is three programs that call this window and I cannot know in advance what program it will be. Despite the window is the same, I have three different NameMapping (because the parent process is not the same).

So, I need a single script routine or keyword which can check the three NameMapping and choose the one that exists to enter the pin code.

What would be the best way to do this ?

7 Replies

  • eykxas's avatar
    eykxas
    Regular Contributor

    Hello. Not at all.

    For now, in my Keywordtest I have this :

     

    The final window (which contains the edit field and the button) is always the same. But the parent Aliases is different, because the final window is called from different program.

     

    When I run this test, only one of these "If" is true. But I don't know which one. (this changes at each run). 

     And, due to the NameMapping timeout, it takes a long time.

    I would like to simplifiy this.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The login window is always the same, properties don't change? However, it has different parents because you have three applications/programs? Therefore you've defined three name mappings for the login window?

     

    How is the application called?

     

    Use if...statements with WaitAliasChild method. You can wait up to a number of seconds before moving on. For example,

    if (AliasObj.WaitAliasChild("App1.Login", 5000).Exists)
      Log.Message("Login 1")
    else if (AliasObj.WaitAliasChild("App2.Login", 5000).Exists)
      Log.Error("Login 2");
    else if (AliasObj.WaitAliasChild("App3.Login", 5000).Exists)
      Log.Error("Login 3");

     

  • eykxas's avatar
    eykxas
    Regular Contributor

    Ok ! Thanks for your reply. Based on your example I created a script able to manage my case.
    But instead of "else if" I use a switch case and a map.

    I set a map() with all my mapped objects, then I parse this map and the first object that exists is passed to the switch.

  • eykxas's avatar
    eykxas
    Regular Contributor

    This is what I doing for now. But I planned to find another method than namemapping to get the Edit field and the button. (If I can do this, the switch will no longer be necessary).

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    That's look good. You could also move the switch statement within the for loop, e.g. 

    for (const [key, value] of arObj) {
      if (value.Exists && value.Visible == true) {
        switch (key):
    	  case "plugin1":
    	    // code
    	    break;
    	  case "plugin2":
    	    // code
    	    break;
    	  default:
    	    // error
      }
    }

    Ensure the code can be maintainable, and other testers can understand it.