Forum Discussion

rmnrdi's avatar
rmnrdi
Contributor
7 years ago

generic popup handler

I have a desktop application that has many programs which can be run from a launchpad. Some of these programs will require confirmation to switch to a different user (for security purposes) and some will not.

 

I can record an operation to be fired from an OnUnexpectedWindow event, but the recording is tied to the name of the module.

 

Here is a sample script:

 

procedure Login;
var settingsNavigator : OleVariant;
var tdlgUserLogIn : OleVariant;
begin
settingsNavigator := Aliases.SettingsNavigator;
settingsNavigator.TMessageForm2.Yes.Keys('[Enter]');
tdlgUserLogIn := settingsNavigator.dlgUserLogIn;
tdlgUserLogIn.edtUserName.Keys('login[Enter]');
tdlgUserLogIn.edtPassword.Keys('[Enter]');
tdlgUserLogIn.Panel1.btnOK.Keys('[Enter]');
end;

 

This login was launched with the SettingsNavigator program. The script then ties everything that happens after that to that program. 

 

I don't want to have to make N of these to only handle the N programs that need a login. I need a generic way to handle the login prompt, regardless of what program opens it.

 

Thanks,

 

 

 

 

 

 

4 Replies

  • NisHera's avatar
    NisHera
    Valued Contributor

    As I understand (let me know if wrong..)

    1) you have many programs starting same way

    2) Some will pop-up log on window

    3) When pop-up, need different log on details...

     

    4) you are scripting with jScript or JavaScrip.

    5) you need generic code to handle log on window/dialog

     

    On my perspective it's not a good practice to handle those with OnUnexpectedWindow  event, because you are expecting those log-on.

     

    My suggestion is write a common function in (jScript ) and call it when ever appears log on dialogue. If JavaScript you can have a class which would inherit a log on function

     

    I assume you know which program you suppose to run. and you know program  need log on or not. If so you have to just call common log on function with matching parameters. 

    • rmnrdi's avatar
      rmnrdi
      Contributor

      Thanks for the reply NisHera.

       

      As I understand (let me know if wrong..)

      1) you have many programs starting same way -Correct

      2) Some will pop-up log on window -Correct

      3) When pop-up, need different log on details... -Logins are the same for the testing I'm doing.

       4) you are scripting with jScript or JavaScript. -I'm using DelphiScript

      5) you need generic code to handle log on window/dialog -Correct

       

      On my perspective it's not a good practice to handle those with OnUnexpectedWindow  event, because you are expecting those log-on.

       

      My suggestion is write a common function in (jScript ) and call it when ever appears log on dialogue. If JavaScript you can have a class which would inherit a log on function. How do I call it just when that login appears? 

       

      I assume you know which program you suppose to run. and you know program  need log on or not. If so you have to just call common log on function with matching parameters. This could change, so I want to make a generic way to login as opposed to hard coding it into each test.

       

      Basically, if any of the programs prompts for a log in, I want it handled, but I don't want to hard-code that into every single test, because we have 20 programs. Each of those have their own test types and test projectss. Smoke, Regression, Funtional... I'd like to have a single event handler in each project that took care of logins.

       

      Thanks,

      R

  • NisHera's avatar
    NisHera
    Valued Contributor

    As I understand (let me know if wrong..)

    1) you have many programs starting same way

    2) Some will pop-up log on window

    3) When pop-up, need different log on details...

     

    4) you are scripting with jScript or JavaScrip.

    5) you need generic code to handle log on window/dialog

     

    On my perspective it's not a good practice to handle those with OnUnexpectedWindow  event, because you are expecting those log-on.

     

    My suggestion is write a common function in (jScript ) and call it when ever appears log on dialogue. If JavaScript you can have a class which would inherit a log on function

     

    I assume you know which program you suppose to run. and you know program  need log on or not. If so you have to just call common log on function with matching parameters. 

    • rmnrdi's avatar
      rmnrdi
      Contributor

      Quick update on my solution.

       

      I found that there's a way to login on the main program launchpad. If I do that first, all other programs will open under those privileges. 

       

      When my app first loads, I have a procedure that logs me in and I'm good from there on out.