Watin script to handle Ajax popup

I am using WatiN testing tool and I am writing C # .net scripts. I have a script where I need to change the theme of my web page, so for that I need to click on the image button which will open an ajax popup with the image and the Apply Theme button which is below the image, now I need to click on the button like so, how to do this please suggest some solution.

+1


a source to share


4 answers


So first click on the button that brings up the popup and .WaitUntilExists () for the button inside the popup.

IE.Button("ShowPopup").click()
IE.Button("PopupButtonID").WaitUntilExists()
IE.Button("PopupButtonID").click()

      



This may not work if the button in the popup exists but is hidden from view. In this case, you can try .WaitUntil () and specify the attribute to look for.

IE.Button("ButtonID").WaitUntil("display","")

      

+4


a source


Ajax popup popup shouldn't be a problem as long as you handle sync control asynchronously. If you are using ajax control instrumentation you can solve it like this

int timeout = 20;
for (i=0; i < timeout; i++)
{
    bool blocked = Convert.ToBoolean(ie.Eval("Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack();"));
    if (blocked)
    {
       System.Threading.Thread.Sleep(200);
    }
    else
    {
        break;
    }
 }

      

With the control visible, you should be able to access it normally.



Watin 1.1.4 added WaitUntil support to controls, but I haven't personally used it.

// Wait until some textfield is enabled
textfield.WaitUntil("disable", false.ToSting, 10);

      

+1


a source


I am not using any ajax control and there is no text box in the popup as I mentioned that there is only an image and a button below it that I need to click to apply this image as a theme.

0


a source


I wrote a post on how I am doing ajax sync since I was having issues with WaitUntilExists: http://lebobitz.wordpress.com/2011/03/06/synchronizing-watin-and-ajax-with-jquery/

0


a source







All Articles