Topic
  • 3 replies
  • Latest Post - ‏2013-10-24T04:06:00Z by TonyNGAN
TonyNGAN
TonyNGAN
34 Posts

Pinned topic Action after AJAX Pop-Up

‏2013-10-19T15:22:44Z |

Dear All,

I'm really sorry to ask question so frequently...hope you guys can help me for the following questions:

Scenario:

I have completed a script to submit a webform, after the form submitted, the webpage will redirect to a new page with a AJAX pop-up

The AJAX pop-up like some transaction page with payment transaction, after the payment completed in the AJAX, the AJAX pop-up will be closed automatically and return a reference number to me.

I can use RFT to input the information for submitting the form, but I would like to know how can I code the script to perform the followings:

  1. Sleep the RFT when the IE page have AJAX pop-up
  2. After the AJAX pop-up closed, resume the RFT and get the reference number to datapool

Many Thanks for your kindly help

Best Regards

Tony

Updated on 2013-10-19T15:22:55Z at 2013-10-19T15:22:55Z by TonyNGAN
  • MrCoolK
    MrCoolK
    66 Posts
    ACCEPTED ANSWER

    Re: Action after AJAX Pop-Up

    ‏2013-10-21T13:02:09Z  

    Hi ,

    There are couple of way to do that.

    1.Sleep the RFT when the IE page have AJAX pop-up

    AjazObject.waitforExistence();//This will make RFT wait till object is available

    Second way is where ever you expect the object to pop up use dynamic code that says get me the active screen and if it is AJAX pop up then do something

    Here is  what i meant.Please rephrase the code as per your need.

    Lets say you get a pop up with a message and you  want to get the message and close it :

     

    public static String getErrorMessageAndClose(){
        IWindow activeWindow = getScreen().getActiveWindow();
        activeWindow.click();
        IWindow[] err=activeWindow.getChildren();
        String errorMessage="";
        String error="";
        for(int i=0;i<err.length;i++)
        {

             errorMessage=err[i].getText().trim();
            if(!(errorMessage.equalsIgnoreCase("OK") ||errorMessage.equalsIgnoreCase("Cancel")||errorMessage.equalsIgnoreCase(""))||errorMessage.equalsIgnoreCase("Yes")||errorMessage.equalsIgnoreCase("No"))
            {
              error=error+" "+errorMessage;
            System.out.println("error is =:"+errorMessage);
            }
            activeWindow.close();
         }

        return error;
    }
     

    This will close the active screen(pop up) and give you the error message if you want RFT to sleep the add sleep(timeInSecond) instead of close .

     

    2.From the previous code i provided you can get the reference number and pass it to datapool.

     

    Thanks

    I hope this helps .Please let us know if this dint help

    Thanks

    Cool K

     

  • cagin.uludamar
    cagin.uludamar
    66 Posts

    Re: Action after AJAX Pop-Up

    ‏2013-10-21T11:53:29Z  

    I'm not familiar with AJAX, but if you can insert AJAX popup as a test object, you can wait until it disappears using a code like while (popup().exists()) sleep(1);

  • MrCoolK
    MrCoolK
    66 Posts

    Re: Action after AJAX Pop-Up

    ‏2013-10-21T13:02:09Z  

    Hi ,

    There are couple of way to do that.

    1.Sleep the RFT when the IE page have AJAX pop-up

    AjazObject.waitforExistence();//This will make RFT wait till object is available

    Second way is where ever you expect the object to pop up use dynamic code that says get me the active screen and if it is AJAX pop up then do something

    Here is  what i meant.Please rephrase the code as per your need.

    Lets say you get a pop up with a message and you  want to get the message and close it :

     

    public static String getErrorMessageAndClose(){
        IWindow activeWindow = getScreen().getActiveWindow();
        activeWindow.click();
        IWindow[] err=activeWindow.getChildren();
        String errorMessage="";
        String error="";
        for(int i=0;i<err.length;i++)
        {

             errorMessage=err[i].getText().trim();
            if(!(errorMessage.equalsIgnoreCase("OK") ||errorMessage.equalsIgnoreCase("Cancel")||errorMessage.equalsIgnoreCase(""))||errorMessage.equalsIgnoreCase("Yes")||errorMessage.equalsIgnoreCase("No"))
            {
              error=error+" "+errorMessage;
            System.out.println("error is =:"+errorMessage);
            }
            activeWindow.close();
         }

        return error;
    }
     

    This will close the active screen(pop up) and give you the error message if you want RFT to sleep the add sleep(timeInSecond) instead of close .

     

    2.From the previous code i provided you can get the reference number and pass it to datapool.

     

    Thanks

    I hope this helps .Please let us know if this dint help

    Thanks

    Cool K

     

  • TonyNGAN
    TonyNGAN
    34 Posts

    Re: Action after AJAX Pop-Up

    ‏2013-10-24T04:06:00Z  
    • MrCoolK
    • ‏2013-10-21T13:02:09Z

    Hi ,

    There are couple of way to do that.

    1.Sleep the RFT when the IE page have AJAX pop-up

    AjazObject.waitforExistence();//This will make RFT wait till object is available

    Second way is where ever you expect the object to pop up use dynamic code that says get me the active screen and if it is AJAX pop up then do something

    Here is  what i meant.Please rephrase the code as per your need.

    Lets say you get a pop up with a message and you  want to get the message and close it :

     

    public static String getErrorMessageAndClose(){
        IWindow activeWindow = getScreen().getActiveWindow();
        activeWindow.click();
        IWindow[] err=activeWindow.getChildren();
        String errorMessage="";
        String error="";
        for(int i=0;i<err.length;i++)
        {

             errorMessage=err[i].getText().trim();
            if(!(errorMessage.equalsIgnoreCase("OK") ||errorMessage.equalsIgnoreCase("Cancel")||errorMessage.equalsIgnoreCase(""))||errorMessage.equalsIgnoreCase("Yes")||errorMessage.equalsIgnoreCase("No"))
            {
              error=error+" "+errorMessage;
            System.out.println("error is =:"+errorMessage);
            }
            activeWindow.close();
         }

        return error;
    }
     

    This will close the active screen(pop up) and give you the error message if you want RFT to sleep the add sleep(timeInSecond) instead of close .

     

    2.From the previous code i provided you can get the reference number and pass it to datapool.

     

    Thanks

    I hope this helps .Please let us know if this dint help

    Thanks

    Cool K

     

    Thanks Cool K,

    Currently I can use another way to detect if the AJAX pop-up has been closed or not by using object.waitforexistence

    Since there will be a transaction number display after the AJAX close, so that is better to use waitforexistence for my case.

    Anyway , many thanks for your kindly help :)!

    Regards

    Tony