I am simulating website with 3G capability using selenium 4 and page load from one to another takes more than 60 seconds which is default timeout. I am overriding it with page load timeout to 120 seconds. But am getting exception org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died error.
So, by this it means it's not taking more than 60 seconds to quit the browser under test.
Even giving explicit wait not helping since its not moving forward with the next line of code in class.
Script has executed till Sign in line of code. Issue happens when page is navigating just on the line of explicit wait
System.setProperty("webdriver.chrome.driver","/Downloads/chromedriver-2");
ChromeDriver driver=new ChromeDriver();
DevTools devTools = driver.getDevTools();
devTools.createSession();
devTools.send(Network.emulateNetworkConditions(
false,
20,
4000,
5000,
Optional.of(ConnectionType.CELLULAR3G)
));
driver.manage().timeouts().pageLoadTimeout(120,TimeUnit.SECONDS);
driver.get("https://www.youtube.com/feed/library");
driver.findElement(By.xpath("//div[@id='button']//yt-formatted-string[contains(text(),'Sign in')]")).click();
WebDriverWait wait=new WebDriverWait(driver, Duration.ofSeconds(120));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@type='email']")));
driver.findElement(By.xpath("//input[@type='email']")).sendKeys("check");
driver.quit();
How to make navigation between pages to have predefined wait time or how to make it come under explicit timeout defined? How to approach this to have a reliable solution? Edit: Code changed after suggesting below