Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible issue with Chromedriver 78, Selenium can not find web element of PDF opened in Chrome

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>

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);

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.

like image 784
Mix Avatar asked Oct 28 '19 10:10

Mix


People also ask

Does Selenium WebDriver work with Chrome?

Through WebDriver, Selenium supports all major browsers on the market such as Chrome/Chromium, Firefox, Internet Explorer, Edge, Opera, and Safari.

What is undetected ChromeDriver?

https://github.com/ultrafunkamsterdam/undetected-chromedriver. Optimized Selenium Chromedriver patch which does not trigger anti-bot services like Distill Network / Imperva / DataDome / Botprotect.io Automatically downloads the driver binary and patches it.

Which version of Selenium is compatible with ChromeDriver?

ChromeDriver is only compatible with Chrome version 12.0. 712.0 or newer. If you need to test an older version of Chrome, use Selenium RC and a Selenium-backed WebDriver instance.


4 Answers

I've run into the same issue.

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.

I tried zsbappa's ChromeOption solution but no joy.

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.

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.

like image 197
wdtj Avatar answered Oct 13 '22 21:10

wdtj


We have faced a similar issue with Chrome 78.0.3904.7, Chromedriver 77/78, Python Selenium 3.141.0.

In our automated Python Selenium tests, we've seen multiple failures where it appears that clicks on elements have not occurred. Even stranger, it appears that the element has become active (as if it were about to be clicked) but the the actual click event never occurred. As a result, page switches etc do not occur resulting in various downstream failures.

By a process of trail and error, we found that using the standard .click() function is now not reliable:

webdriver_element.click()

But using Action Chains does appears to be reliable:

ActionChains(context.browser).click(webdriver_element).perform()

It's not clear why this is the case. The failures began as soon as we upgraded to Chrome 78.0.3904.7. We're using Chromedriver 77.0.3865.90 but the same tests pass reliably on Chrome 77.x versions therefore it appears something is wrong or has changed in Chrome 78.

like image 3
Oli Boorman-Humphrey Avatar answered Oct 13 '22 19:10

Oli Boorman-Humphrey


By adding the following argument I have solved my problem.

   ChromeOptions options = new ChromeOptions();
    options.addArguments("--disable-gpu");
    options.addArguments("--disable-extensions");
    options.setExperimentalOption("useAutomationExtension", false);
    options.addArguments("--window-size=1920,1080");
    options.merge(seleniumCapabilities);
    driver = new ChromeDriver(options);
like image 1
Zakaria Shahed Avatar answered Oct 13 '22 21:10

Zakaria Shahed


I have faced the same issue when trying to access a tab inside an iframe , it used to work fine on version 76. Now that has updated itself to 78, it's failing. Have tried waits , implicit waits , sleep , locate the elements using xpath, CSS, id , switch context , scroll until view , etc.., with no luck. I'm using windows 10 , 1809. I don't know if this is happening in other OS.

Here is the question I raised :

Problem using chromedriver 78.0.3904.70 locators

like image 1
DavidRYV Avatar answered Oct 13 '22 19:10

DavidRYV