This is a migrated thread and some comments may be shown as answers.

Test Studio : Detect dialog before handling it

3 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Iron
Nick asked on 02 Mar 2020, 10:26 AM

How can I detect dialog (Logon) existence before handling it ?

Here is a short description of tests structures :

 

Authentication Test

  1. Navigate to URL
  2. Logon using Dialog
  3. Wait for page content loading

Someother Test

  1. Execute Authentication Test
  2. Click on button...

Currently, in the application being tested, requirements have changed so that in the Authenticate Test, it is really needed to detect a dialog existence before handling it (step 2) : that means Step 2 can be bypassed sometimes but required some others (please, do not ask why :) ).

That leads to a fail (no dialog to is found for handling) or success (Dialog is found).

What we have tried is marking the ContinueOnFailure property of the Step 2 in Authenticate Test to True but, wrong idea : when calling Authenticate Test within Someother Test (test as step)ContinueOnFailure does not ignore the Logon failed step stopping Someother Test execution to step 1.

A workaround for this could be marking Step 1 in Someother Test ContinueOnFailure property also to true but Noo, we already have tons of tests calling it and we dislike this approach.

So, Is there a solution?

   

3 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 02 Mar 2020, 02:07 PM

Hello Nick Cephas,

Thank you for sharing details about the test scenario that you want to automate. I have a suggestion for you, how to redesign the Authentication Test, so you can reuse it in both scenarios. Please find more details below.

  • You need to define and add the LogonDialog for monitoring in a coded step as step 1 in your test and configure the username and password. Do not navigate in the same coded step (as it is in the example), because we want to keep them separate and see if the browser navigated successfully or not.
  • Now comes the standard Navigate to URL step.
  • In the next step, we need to make sure that we remove the LogonDialog from the dialogs collection. Since we added it in a coded step, we should also remove it in a coded step. We are not interested to know if it appeared and was handled, or did not appear at all. You can use the code sample below.
    IDialog dialog = Manager.DialogMonitor.Dialogs.Last();
    Log.WriteLine(dialog.ToString());
    
    if(dialog.ToString().Contains("LogonDialog")){
        Manager.DialogMonitor.RemoveDialog(dialog);
        Log.WriteLine(Manager.DialogMonitor.Dialogs.Count.ToString());    
    }
  • Proceed with a wait for exists step against an element on the page and continue with the automation

The above approach and coded solution will handle the dialog if it appears and do nothing if it does not. Please keep in mind that this method for handling dialogs will not cause the coded steps to fail and this is why I suggest you use some kind of wait or verification step in your Authentication Test.

I hope this helps you with the test scenario. Please do not hesitate to contact us again, if you need further assistance.

Regards,
Plamen Mitrev
Progress Telerik

 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Nick
Top achievements
Rank 1
Iron
answered on 02 Mar 2020, 02:50 PM

Sure, I have already been thinking about that but the big issue with that approach is that user credentials will appear as plaintext as opposed to Telerik Dialog Handler which gives us the ability to encrypt password or not.

We work as a team, so...

Any workaround for that?

0
Plamen Mitrev
Telerik team
answered on 04 Mar 2020, 01:07 PM

Hi Nick Cephas,

I understand your concerns and I can propose you 2 different approaches. Please find more details about the suggestions below.

- You can have a dedicated user or multiple users for testing purposes that you and your colleagues use. That way you should not be concerned with exposing the login details in your test. Please discuss internally if that is an option for you.

- Another possibility is to read the username and password from a local text file on a specific location and pass it to the dialog. That text file should not be in the Test Studio project's folder and any other folder that is shared with other people. That way you can disclose the credentials and still use the coded step approach to handle the logon dialog.

I hope the above suggestions help you setup your tests and continue with the automation. I remain available to continue our discussion and help you with the test scenario at hand.

Regards,
Plamen Mitrev
Progress Telerik

 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Nick
Top achievements
Rank 1
Iron
Answers by
Plamen Mitrev
Telerik team
Nick
Top achievements
Rank 1
Iron
Share this question
or