tags:

views:

1665

answers:

4

Hi

I'm using WatiN testing tool and i'm writing c#.net scripts. I've a scenario where i need to change the theme of my web page, so to do this i need to click on a image button which opens a ajax popup with the image and "Apply Theme" button which is below the image now i need to click on the button so how to do this please suggest some solution.

A: 

The Ajax pop-up itself shouldn't pose a problem if you handle the timing of the control loading asynchronously. If you are using the ajax control toolkit, 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 then should be able to access it normally.

Watin 1.1.4 added support for WaitUntil on controls as well, but I haven't used it personally.

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

I'm not using any ajax control toolkit and in the popup there is no text field as i've mentioned there is only a image and a button below it, which i need to click in order to apply that image as theme.

+1  A: 

So first click your button that throws 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 in the case the button on the popup exists but is hidden from view. In that case you could try the .WaitUntil() and specify an attribute to look for.

IE.Button("ButtonID").WaitUntil("display","")
Corey Downie
Thanks for replying but the method is not working. wn i click on the image to aplly theme the popup appears has a new window (not as windows internet explorer) it contains image in the top and a button ("Apply Theme") below it.In the title panel there is maximize, minimize and close button. I need to click on the button ("Apply Theme") to make the theme apply to the main window.
I'm not too sure what your asking here. You basically need the ID or some other way to 'get' the 'Apply Theme' button with WatiN. Once you have that, you simply need to .WaitUntilExists(), and then .Click() that button.
Corey Downie
A: 

hi ,

Help required in how to handle the click of a table column header link button which calls asynchronusly(uses AJAX) in WATIN

I currently have a table column, on click of that column header , all the items under that column are sorted in ascending or dsecnding order.

.This table colummn header link button makes use of AJAX to do the post back.

Now i not getting a way to wait untill the completion of the post back. i tried the following steps

Link myLink = table.Link(Find.ByText(new Regex(columnName))); myLink.ClickNoWait(); myLink.WaitForComplete();

then didnt work. Again i tried with

Link myLink = table.Link(Find.ByText(new Regex(columnName))); myLink.ClickNoWait(); System.Threading.Thread.Sleep(3000);

this above code works properly for some time. If i keep on clicking the column again and again then it will not wait for the complete post back :( .Here is where i am facing the trouble. I dont know how to handle the ajax request in Watin on click of a button or a link button.I read in few blogs that , "WaitUntil" is helpful in ajax call ... but i am not able to use this for my table column header link button.

also i tried with myIE.WaitUntilContainsText(columnName); , but here also no hopes :( .Its also not working

Could anyone please tell me how to handle the ajax calls for a table column header link button in WATIN ? .Thanks in advance for your patience and help :).

Thanks again Keshav

keshav, this should be a separate question on its own. (Or have you found an answer to it? In which case, it would help others to post it here.)
David White