Reputation: 3
Here is the scenario:
This second getWindowHandles() call is causing my script to timeout and I'm not sure why. Could someone help me figure out what's going on with this second call? Everything is working as expected until step 4
link.click();
ArrayList<String> handles2 = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(handles2.get(1));
((JavascriptExecutor)driver).executeScript("window.print()");
ArrayList<String> handles3 = new ArrayList<String> (driver.getWindowHandles());
Maybe useful information:
Error Message:
org.openqa.selenium.ScriptTimeoutException: script timeout (Session info: chrome=86.0.4240.183) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_261' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 86.0.4240.183, chrome: {chromedriverVersion: 86.0.4240.22 (..., userDataDir: C:\Users\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Upvotes: 0
Views: 593
Reputation: 3
The issue was the print dialog causing the main thread to lock out.
You are able to use the Robot class as suggested by @pcalkins. But I used the SetTimeout function.
Reference: ChromeDriver - Timeout when trying to print page with javascript
Upvotes: 0