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!

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
farmas
  • 51
  • 1
  • 3

1 Answers1

2

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: How can I make my Selenium tests less brittle?

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

Community
  • 1
  • 1
MariangeMarcano
  • 921
  • 1
  • 8
  • 20