tags:

views:

443

answers:

2

I have a GridView control with sorting enabled inside an UpdatePanel. I used Selenium IDE to record a test that clicks on the sort link of the table, but when I try to execute the test it get's stuck on the click command. Looking at the log I see:

[info] Executing: |click | link=Name | | 
[error] Timed out after 30000ms

I haven't tried it with Selenium-RC yet, I don't know if it will be any different. I don't want Selenium to wait for anything. Any ideas of how to work around it?

Thanks!

+1  A: 

when using selenium + Ajax (or the page just get refresh under certain conditions).

I usually use:

selenium.WaitForCondition

or I created the following code recently (the page uses frames).

    public bool AccessElementsOnDynamicPage(string frame, Predicate<SeleniumWrapper> condition)
    {
        DateTime currentTime = DateTime.Now;
        DateTime timeOutTime = currentTime.AddMinutes(6);
        while (currentTime < timeOutTime)
        {
            try
            {
                SelectSubFrame(frame);
                if (condition(this))
                    return true;
            }
            catch (SeleniumException)
            {
                //TODO: log exception
            }
            finally
            {
                currentTime = DateTime.Now;
            }
        }
        return false;
    }

    public bool WaitUntilIsElementPresent(string frame, string locator)
    {
        return AccessElementsOnDynamicPage(frame, delegate(SeleniumWrapper w)
        {
            return w.IsElementPresent(locator);
        });

    }

    public bool WaitUntilIsTextPresent(string frame, string pattern)
    {
        return AccessElementsOnDynamicPage(frame, delegate(SeleniumWrapper w)
        {
            return w.IsTextPresent(pattern);
        });
    }

Soon you will get to the point you will need selenium RC integrated on your development environment, for this I recommend you to read: http://stackoverflow.com/questions/466819/how-can-i-make-my-selenium-tests-less-brittle/1114153#1114153

It is around waiting but for specific elements that should be (or appear) on the page.

A: 

Thanks for the link Dave.

I found the answer in this post: http://stackoverflow.com/questions/1391718/selenium-ide-click-timeout. Not exactly what I wanted to do, but it works.

farmas