Selenium:Timed out receiving message from renderer exception when switching to new tab

心不动则不痛 提交于 2019-12-11 19:54:51

问题


I am trying to verify the content of PDF. In our application when we click on a link a new tab opens with embedded pdf[No URL in new tab], my task is to verify the content of PDF.

I am trying to switch to new PDF and do Ctrl + A and Ctrl + c as below.

ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles());
            for (String string : tabs) {
                System.out.println("tab id:: "+string);
            }       

            driver.switchTo().window(tabs.get(1));

            driver.switchTo().defaultContent();
            System.out.println(driver.switchTo().window(tabs.get(0)).getTitle()); //first tab title
            System.out.println(driver.switchTo().window(tabs.get(1)).getTitle()); //second tab title

                String selectAll = Keys.chord(Keys.CONTROL,Keys.chord("a"));
                String copy = Keys.chord(Keys.CONTROL,Keys.chord("c"));


                //driver.switchTo().defaultContent();
                pause(3000);
                Actions action = new Actions(driver);

                action.sendKeys(selectAll).perform(); 
                  pause(3000);
                  new Actions(driver).sendKeys(copy).build().perform();

But i am getting exception when trying to perform any activity with the new tab. System.out.println(driver.switchTo().window(tabs.get(1)).getTitle());

Below is the exception.

[1528016019.920][SEVERE]: Timed out receiving message from renderer: 40.000
[1528016019.925][SEVERE]: Timed out receiving message from renderer: -0.019


org.openqa.selenium.TimeoutException: timeout
  (Session info: chrome=66.0.3359.181)
  (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 41.16 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'D2RMHQN2', ip: '10.165.226.152', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_152'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73), userDataDir=C:\Users\SG0221~1\AppData\Local\Temp\scoped_dir10444_7193}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=66.0.3359.181, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: abb6795a426b25128731ab96ae8db7fd
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701)
    at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:320)
    at com.resources.PDFReader.verifyPDFContent(PDFReader.java:106)

ChromeDriver version = 2.35.528161 Chrome version = 66.0.3359.181

Any one came across this kind of issue , please let me know the solution. Thank you.


回答1:


It is a config issue ChromeDriver 2.35 supports Chrome v62-64

You need ChromeDriver 2.39 or 2.38 as you are using Chrome 66



来源:https://stackoverflow.com/questions/50664871/seleniumtimed-out-receiving-message-from-renderer-exception-when-switching-to-n

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