本文介绍了Chromedriver 78可能存在问题,Selenium找不到在Chrome中打开的PDF的Web元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到我的Google Chrome浏览器未更新到版本78,我的代码才能正常工作.我还将chromedriver更新为版本78.0.3904.70.因此,我无法再使用Selenium WebDriver和Java查找id ='plugin'的WebElement:

Until my google Chrome wasn't updated to version 78 my code worked fine. I also updated the chromedriver to version 78.0.3904.70. So I am not able anymore to find WebElement with id='plugin' using Selenium WebDriver and Java:

<html>
<div id="content">
<embed id="plugin" type="application/x-google-chrome-pdf" src="http://??????????/offer_printed.php?printable=yes&amp;reanudar=&amp;>
</div>
</html>

除了那部分之外,我的测试工作正常.我以前从未遇到过类似的问题.我也试图找到WebElement id ='content',但是我收到了同样的错误.

Other than that part my tests are working fine. I never had a similar issue before. I also tried to find WebElement id='content' but I am receiving the same error.

WebDriverWait wait = new WebDriverWait (driver, 90);
WebElement scrollvalid = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("plugin")));

scrollvalid.sendKeys(Keys.PAGE_DOWN);                       scrollvalid.sendKeys(Keys.PAGE_DOWN);

我的自动化脚本应找到PDF元素并向下滚动页面.相反,我收到此错误:org.openqa.selenium.TimeoutException:等待90秒后等待By.id定位的元素可见:插件

My automation script should find the PDF element and scroll the page down. Instead, I am receiving this error: org.openqa.selenium.TimeoutException: Timed out after 90 seconds waiting for visibility of element located by By.id: plugin

有人遇到类似的问题吗?预先感谢.

Is anybody facing a similar issue? Thanks in advance.

推荐答案

我遇到了同样的问题.

I've run into the same issue.

显然,Chrome浏览器会自动更新.昨天(19年10月29日),我的ChromeDriver开始抱怨它与Chrome 78不兼容.我将驱动程序更新为78版本.尝试查找我确认存在的元素时,我开始随机获得org.openqa.selenium.NoSuchElementException异常.当我使用断点时,findElement [s]也可以工作.我还尝试了隐式等待,但仅获得了有限的成功.

Apparently Chrome automatically updates itself. Yesterday (Oct 29 '19) My ChromeDriver started complaining that it was not compatible with Chrome 78. I updated the driver to the 78 version. I started to get random org.openqa.selenium.NoSuchElementException exceptions when trying to find elements that I confirmed were there. The findElement[s] also work when I used breakpoints. I also tried implicit waits, with only limited success.

我尝试了zsbappa的ChromeOption解决方案,但没有任何乐趣.

I tried zsbappa's ChromeOption solution but no joy.

Google很难获取旧版本的Chrome,但我在 https://www.neowin.net/news/google-chrome-76-offline-installer/.当心,在线安装程序将安装最新版本.我回到了76位司机,一切都很好.我所有的硒测试都可以再次使用.

Google makes it hard to get old versions of Chrome, but I found version 76 at https://www.neowin.net/news/google-chrome-76-offline-installer/. Beware, the online installer installs the latest version. I reverted to the driver for 76 and all is good. All my Selenium tests are working again.

我的结论是,Chrome 78及其关联的驱动程序处于竞争状态,Selenium试图在完成之前查询该网页.

My conclusion is that the Chrome 78 and it's associated driver has a race condition where Selenium attempts to interrogate the web page before it's complete.

这篇关于Chromedriver 78可能存在问题,Selenium找不到在Chrome中打开的PDF的Web元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 19:07