如何在Selenium Webdriver

时间:2015-06-11 07:32:55

标签: selenium

我已登录其中一个网站的帐户。登录后,单击该页面中的按钮。但页面继续加载而不显示下一页。

我想要的是,如果页面继续加载而没有给出任何响应,我需要停止执行脚本。

我尝试过使用下面的代码。但它有效 " driver.manage()。timeouts()。pageLoadTimeout(500,TimeUnit.MILLISECONDS);"

任何人都可以帮我解决这个问题

2 个答案:

答案 0 :(得分:0)

如果您使用的是firefox,请使用带有selenium的firefox配置文件,并将 network.http.connection-timeout 设置为秒(例如,我将其设置为10秒) -

在Java中,

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.http.connection-timeout", 10);

答案 1 :(得分:0)

要停止页面加载,您可以使用此

public void stopPageLoading() {
            JavascriptExecutor js = (JavascriptExecutor) driver;
            js.executeScript("return window.stop");
        }
相关问题