Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

When I am using a proxy in webdriver like FirefoxDriver, if the proxy is bad then the get method will block forever. I set some timeout parameters, but this did not work out.

This is my code:

FirefoxProfile profile = new FirefoxProfile();

profile.setPreference("general.useragent.override", ua);    

Proxy p = new Proxy();




// create a driver

WebDriver driver = new FirefoxDriver(profile);

driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);


The call to driver.get will block for ever, but I want it to wait for 30 seconds and if the page is not loaded then throw an exception.

1 Answer

0 votes
by (62.9k points)

Use this code:


this statement will return immediately.

And after that, you can add a WebDriverWait with a timeout to check if the page title or any element is ok.

Hope this will help you.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium automation course!

Browse Categories