Chromedriver 78 可能存在问题,Selenium 找不到在 Chrome 中打开的 PDF 的 Web 元素 [英] Possible issue with Chromedriver 78, Selenium can not find web element of PDF opened in Chrome

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

问题描述

在我的谷歌浏览器没有更新到版本 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 会自动更新.昨天(2019 年 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 的驱动程序,一切都很好.我所有的 Selenium 测试都重新开始工作了.

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 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆