Forum Discussion

kaiiii's avatar
kaiiii
Regular Contributor
5 years ago

page is taking too much time after click on Confirm dialoxbox

Hello,

Here i am trying to handle a confirm dialogbox when i manually click on "OK" button page is not taking too much time to load but when i execute it with my script it's taking too much time to load the page.

Also i had tried all kind of Action methods like(Click, ClickM, ClickButton, DblClick)

Please check the below code

 

Set Ok_dialogbox = page.FindChild("ObjectType", "Confirm", 5000)

If (Ok_dialogbox.Exists) Then

     page.Confirm.Button("OK").Click

     Log.Message("Message text: " + page.Confirm.Message)

End IF

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    You did not provide too much information about what is taking too much time, what is your definition of 'page load' and what do you get in a test log, but I see some potential problem in your code:

    >     page.Confirm.Button("OK").Click

    >     Log.Message("Message text: " + page.Confirm.Message)

    Technically, after you close Confirm dialog via .Click(), Confirm dialog (presumably) is closed and disposed of. And on the next line you are trying to get some property (Message) of potentially non-existing object.

    What will happen next depends on a lot of factors:

    -- If the dialog is not disposed of you should get the value of the Message property without delay;

    -- If test code executes faster that the dialog is destroyed, then also I would not expect execution delays;

    -- If the dialog is already disposed of by the moment of getting the value of the Message property, TestComplete will start to search for the dialog a-new and this obviously will slow down execution speed. The results depends on the search result - if some other Confirm dialog is found, then the value of its Message property will be posted to test log. If search fails, you should get a warning/error in test log stating that the sought for object was not found.

     

  • Wamboo's avatar
    Wamboo
    Community Hero

    In my opininion you need to wait a little longer with the click action.

     

    If you use the .Exist method without any condition TestComplete waits only certain portion of time and then executiing next line of your script.

     

    Try to use this function:

     

    function waitForObj(obj, counter) {
      var counter = counter || 60;
      for (var i = 1; i <= counter; i++) {
          if (obj.Exists == false) {
              aqUtils.Delay(1000);
          } else {
              return true;
              //break; // or use just break break 
          }
      }
    }

    I know that this is JS but the code is simple so you can change it to VB if you want.

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi kaiiii,

     

    Do the suggestions given here help you resolve the issue? Please mark the reply which you decided to follow as a solution.