pageLoadTimeout not working for Firefox browser in selenium

早过忘川 提交于 2020-03-21 06:38:13

问题


In firefox browser pageLoadTimeout is not working whereas same code is working for chromium browser.

public static WebDriver startApplication(WebDriver driver, String browserName, String appURL) {
    switch (browserName.toLowerCase()) {
        case "chrome":
            WebDriverManager.chromedriver().setup();
            driver = new ChromeDriver();
            break;
        case "firefox":
            WebDriverManager.firefoxdriver().setup();
            driver = new FirefoxDriver();
            break;
        case "ie":
            WebDriverManager.iedriver().setup();
            driver= new InternetExplorerDriver();
            break;
        case "edge":
            WebDriverManager.edgedriver().setup();
            driver= new EdgeDriver();
            break;
        case "opera":
            WebDriverManager.operadriver().setup();
            driver = new OperaDriver();
            break;

        default:
            System.out.print("Browser not supported");
    }
    driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    driver.get(appURL);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    return driver;
}

After i click the submit button, the backend may take more time(about 40 sec) to produce the output. I have to wait until i get the response of api call after clicking submit button i.e to fully load webpage.

I am using page object model. After clicking button i am using following code to fetch the output:

myTestPage.getOutput();

This codes works fine for Chromium Browser whereas in firefox, it doesn't wait for 60 sec pageLoadTimeout. It only waits for about 5sec.

Selenium-java version: 3.141.59

geckodriver version: 0.26.0

Update: After clicking the submit button my page doesn't navigate to another page. The output is appeared in the same page.

The issue is not similar to this question . The question is related to the driver continues to wait till the complete page is loaded but mine is just opposite that is the driver doesn't wait till the complete page is loaded. Mine issue only occured in firefox browser.

来源:https://stackoverflow.com/questions/60390926/pageloadtimeout-not-working-for-firefox-browser-in-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!