The problem of using Selenium to automate the feedback that is inside the ASP.NET UpdatePanel

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

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

      

I haven't tried this with Selenium-RC yet, I don't know if it will be otherwise. I don't want Selena to wait for anything. Any ideas on how to get around this?

Thank!

+2


source to share


2 answers


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

I usually use:

selenium.WaitForCondition

or I recently created the following code (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);
        });
    }

      

You will soon get to the point where you need an integrated RC selenium server in your development environment, so I recommend you read: How to make selenium tests less fragile?

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

+2


source


Thanks for the link Dave.



I found the answer in this post: Selenium IDE click () timeout. Not exactly what I wanted to do, but it works.

+1


source







All Articles