【问题标题】:Problem using Selenium to automate a postback link that is inside an ASP.NET UpdatePanel [duplicate]使用 Selenium 自动执行 ASP.NET UpdatePanel 内的回发链接时出现问题 [重复]
【发布时间】:2010-11-28 00:27:01
【问题描述】:

我有一个 GridView 控件,在 UpdatePanel 中启用了排序功能。我使用 Selenium IDE 记录了单击表的排序链接的测试,但是当我尝试执行测试时,它卡在了单击命令上。查看我看到的日志:

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

我还没有用 Selenium-RC 尝试过,我不知道会不会有什么不同。我不希望 Selenium 等待任何事情。关于如何解决它的任何想法?

谢谢!

【问题讨论】:

  • 发布你的gridView的html代码

标签: selenium


【解决方案1】:

当使用 selenium + Ajax 时(或页面在某些条件下刷新)。

我通常使用:

硒.WaitForCondition

或者我最近创建了以下代码(页面使用框架)。

    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);
        });
    }

很快你就会明白你需要在你的开发环境中集成 selenium RC,为此我建议你阅读: How can I make my Selenium tests less brittle?

它是在等待,但对于应该(或出现)在页面上的特定元素。

【讨论】:

    猜你喜欢
    • 2021-04-07
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    • 1970-01-01
    • 2015-10-24
    • 1970-01-01
    • 2016-08-06
    相关资源
    最近更新 更多