Selenium在页面完全加载之前等待弹出执行

时间:2011-04-02 17:22:11

标签: selenium

我试图抓取源html的弹出窗口(使用waitForPopUp和getHtmlSource);然而,selenium没有等待弹出窗口完全加载目标内容,因此我得到了调用的代码来获取内容(请让我知道实际的术语是什么)。

有人能告诉我在抓取源代码之前我可以使用哪个selenium函数让脚本等待目标加载吗?

感谢。

3 个答案:

答案 0 :(得分:2)

clickAndWaitwaitForPageToLoadopen只是您可以用来等待主页面完全加载的一些功能示例。它们是阻止的,因此请立即致电waitForPopUp

答案 1 :(得分:0)

您需要指定窗口ID和超时时间。来自Selenium IDE -

waitForPopUp(windowID, timeout)
Arguments:

    * windowID - the JavaScript window "name" of the window that will appear (not the text of the title bar) If unspecified, or specified as "null", this command will wait for the first non-top window to appear (don't rely on this if you are working with multiple popups simultaneously).
    * timeout - a timeout in milliseconds, after which the action will return with an error. If this value is not specified, the default Selenium timeout will be used. See the setTimeout() command.

Waits for a popup window to appear and load up.
b / w你是否支持区域51的Selenium提案 - http://area51.stackexchange.com/proposals/4693/selenium 这个提议得到了SeleniumHQ的支持,我们需要更多的用户提交它才能让它看到日光。

答案 2 :(得分:0)

在导致弹出窗口出现的命令(通常是click)之后直接运行selectPopUpAndWait