問(wèn)題描述
在我的谷歌瀏覽器沒(méi)有更新到版本 78 之前,我的代碼運(yùn)行良好.我還將 chromedriver 更新到版本 78.0.3904.70.所以我再也無(wú)法使用 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&reanudar=&>
</div>
</html>
除此之外,我的測(cè)試工作正常.我以前從未遇到過(guò)類似的問(wèn)題.我也試圖找到 WebElement id='content' 但我收到了同樣的錯(cuò)誤.
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);
我的自動(dòng)化腳本應(yīng)該找到 PDF 元素并向下滾動(dòng)頁(yè)面.相反,我收到此錯(cuò)誤:org.openqa.selenium.TimeoutException:90 秒后超時(shí)等待 By.id 定位的元素的可見(jiàn)性:插件
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
有人遇到過(guò)類似的問(wèn)題嗎?提前致謝.
Is anybody facing a similar issue? Thanks in advance.
推薦答案
我也遇到了同樣的問(wèn)題.
I've run into the same issue.
顯然 Chrome 會(huì)自動(dòng)更新.昨天(2019 年 10 月 29 日)我的 ChromeDriver 開(kāi)始抱怨它與 Chrome 78 不兼容.我將驅(qū)動(dòng)程序更新到 78 版本.在嘗試查找我確認(rèn)存在的元素時(shí),我開(kāi)始隨機(jī)出現(xiàn) org.openqa.selenium.NoSuchElementException 異常.當(dāng)我使用斷點(diǎn)時(shí), findElement[s] 也可以工作.我也嘗試過(guò)隱式等待,但效果有限.
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 解決方案,但沒(méi)有任何樂(lè)趣.
I tried zsbappa's ChromeOption solution but no joy.
Google 很難獲得舊版本的 Chrome,但我在 https://www.neowin.net/news/google-chrome-76-offline-installer/.請(qǐng)注意,在線安裝程序會(huì)安裝最新版本.我恢復(fù)了 76 的驅(qū)動(dòng)程序,一切都很好.我所有的 Selenium 測(cè)試都重新開(kāi)始工作了.
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.
我的結(jié)論是 Chrome 78 及其相關(guān)驅(qū)動(dòng)程序存在競(jìng)爭(zhēng)條件,即 Selenium 會(huì)在網(wǎng)頁(yè)完成之前嘗試詢問(wèn)網(wǎng)頁(yè).
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.
這篇關(guān)于Chromedriver 78 可能存在問(wèn)題,Selenium 找不到在 Chrome 中打開(kāi)的 PDF 的 Web 元素的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!