ChromeDriver error "unknown error: cannot get automation extension" - selenium-webdriver

Since the 7th of February all my tests are failing with the same error; the log entry reads:
RESPONSE MaximizeWindow unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=57.0.2987.21)
I'm not sure if this is caused by a Chrome update or something else - the message is vague enough as it is.
EDIT: I am using C#, and the latest Chromedriver.

You need the latest version of chromedriver.exe. https://sites.google.com/a/chromium.org/chromedriver/downloads
This is needed for chromedriver version 57+
I was having this same issue. Once I updated the chromedriver version everything worked again.

Suddenly got this error -> Additional information: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension..
This issue exists even when using ChromeDriver 2.29
What solved it though was removing this line.
driver.Manage().Window.Size = new Size(1024, 768);
A quick fix but really not the one I've been looking for.
Would be great to still use the sizing mechanism.

This could probably because the environment where you are running the tests is blocking all the third party extensions in chrome browser. Give it a try with disabling the extensions.
something like below:
ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(o);

As mentioned above, it's related to the chromedriver.
In the release notes of version 2.33, it's mentioned that they fixed an issue related to resizing/positioning.
Latest Release: ChromeDriver 2.33
Supports Chrome v60-62
Changes include:
Fixes a bug which caused Resizing/Positioning Window commands to fail on Chrome 62+.

Instead of downloading the chrome driver manually, it's better to update the version of chromedriver in package.json (or similar file) and fire npm install to get the latest version auto downloaded.

Try to use Webdrivermanager from
io.github.bonigarcia library
It will automatically load the latest version of your's webdriver and so you will not need to update it from time to time.
Just call for example:
ChromeDriverManager.getInstance().setup();
before calling the webdriver itself to get the latest version of ChromeDriver.

Updating your chrome driver exe would not actually fixed this issue, if you observed, it is happening while you're re-sizing chrome
driver.Manage().Window.Maximize();
Try to comment this line and try again.
It's a quick fix, I'll update my answer once I find the root cause of this(however it seems because of browser update as nothing was changed in code for me).
Update:
For me, it seems to be because of browser update as once I updated again this issue was gone.

I faced the issue, too. I have replaced the existing chrome driver which I had in my C folder with new chrome driver downloaded from https://sites.google.com/a/chromium.org/chromedriver/downloads, which resolved the issue.

I had the same issue. Just downloaded the latest release of chromedriver and that solved the problem.
https://sites.google.com/a/chromium.org/chromedriver/downloads

With the last headless version, you can't resize the window as there isn't any window anymore.
For my own case, I was experiencing this issue with behat, I used to resize the window with previous versions of chrome of firefox, I surround the following line:
$this->getSession()->resizeWindow(1600, 1200, 'current');
with a simple check on the driver:
if (($this->getSession()->getDriver() instanceof Selenium2Driver)) {
$this->getSession()->resizeWindow(1600, 1200, 'current');
}

I had started getting the same error in April, shortly after this question. I was able to get around it by installing a new beta version and starting like so:
webdriver-manager start --versions.standalone 3.0.0-beta4 --versions.chrome=2.28
This was working perfectly until a few days ago. I tried removing the offending setSize() from my Protractor conf file and it works again. But whenever my tests start, it also spawns another Chrome window navigated to chrome://settings/help. Weird.
I checked my Chrome update history and see it updated from v61 to v62 last week, so that must have broken it. I guess I need to update my driver once more.
Update: For those that want to quickly know how to update their driver:
webdriver-manager update --versions.chrome=2.33
Don't forget to specify the driver when starting the server.

Thanks
for this -- it helped me after so much R&D
cannot-get-automation-extension
ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(o);

My issue got resolved post adding this comment, thankyou so much.
ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
o.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(o);

update your protractor and run your test cases it will start executing, there are few new stuff added from Protractor, this method worked for me.
update protractor - npm install -g protractor
update webdrvier - webdriver-manager update

it supports the higher versions of chrome driver 2.29.
pls. find the latest chrome drivers in http://www.seleniumhq.org/download/

Related

Value attribute not present on input element | AngularJS, Chrome 91, Protractor

After updating chrome driver to ChromeDriver 91.0.4472.19
The value attribute have dissapeared from the input elements. Protractor cannot access the value attribute.
let x = await xDiv.getEl("#xInput").getAttribute('value');
// x = null
Using the Chrome Dev Tools, I am also not able to see the value attribute of any input element in the markup.
Using AngularJS 1.5.8 and Protractor/Selenium 3.141.59
The problem you described is actually a bug in chromedriver https://bugs.chromium.org/p/chromium/issues/detail?id=1205107. It happened because of the change in chrome browser related to W3C compliance
As you can see, the plan is to fix the bug, however it is still in progress.
Meanwhile, I recommend you 2 workarounds:
you can use chromedriver version 90. The latest version available is here https://chromedriver.storage.googleapis.com/LATEST_RELEASE_90.0.4430
I know that under normal circumstances this would throw incompatibility error, but somehow chromedriver 90 works with chrome 91.
You can downgrade chromedriver by running this command
webdriver-manager update --gecko=false --versions.chrome 90.0.4430.24
Note sometimes you have global, project local and Protractor specific installations of webdriver-manager. The command I gave will install chromedriver globally. In order to install locally you need to find the path to your webdriver-manager and run command like this
node ./node_modules/protractor/node_modules/webdriver-manager update --gecko=false --versions.chrome 90.0.4430.24
And some of you may need to run command in sudo mode. Keep it in mind
Instead of elem.getAttribute('value') try to go with browser.executeScript('return arguments[0].value', elem); multiple users claimed it works for them
Additionally, read this answer https://stackoverflow.com/a/67888592/9150146 that proposes more hacky solutions

How to use old chrome version in rsDriver

rsDriver(browser="chrome",port=4450L, chromever="74.0.3729.6")
the above command doesn't work since the chrome version mentioned is no longer supported(which used to work before) - since binman::list_versions("chromedriver") doesn't list it anymore.
i want to use the older version of chrome - anything before 75.
Is there any other method?
I also downloaded "74.0.3729.6" driver, but don't know how to use the downloaded driver in rsDriver.
use this code "binman::list_versions("chromedriver")" to see available versions of chrome then add it to rsDriver(chromever = "88.0.0.01") as an example

Lost UI Shared Context Error - Running protractor tests in headless chrome

I am attempting to run protractor tests locally using chrome but in headless mode, I have seen the docs and added the appropriate options to my config file:
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
chromeOptions: {
args: [ '--headless', '--disable-gpu', '--window-size=800,600' ]
}
}
Upon running, I encounter the following error:
[1009/122000.081:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
I tried removing the --disable-gpu flag as I read this may not be needed in future version of Chrome. I currently have latest Chrome installed (69.0.3497.100) and am using windows 7.
What do I need to do in order to get the tests running in headless mode? My intention is to check I can run in headless mode fine locally and then I want to get it running also in Chrome headless mode on a linux Jenkins node, where we are currently using XVFB but its proving to be too flaky with timeouts in tests for example.
Thanks
EDIT
With regards to others marking this as a duplicate - I should have said that my tests fail to run when I attempt to use the headless option, without the chrome options set, Chrome launches as expected and the test run and pass successfully.
My tests fail with no such element found type errors and if I view the screenshots taken on the failures, I just see a white square inside a black background (probably as per the --window-size option I was setting)
As you mentioned you are using Chrome headless mode on a linux Jenkins node you need consider a few factors as follows:
--disable-gpu
When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome mentioned that :
--disable-gpu \ # Temporarily needed if running on Windows.
A note was added as :
Right now, you'll also want to include the --disable-gpu flag if you're running on Windows.
As per the discussion Headless: make --disable-gpu flag unnecessary it was clear that :
The --disable-gpu flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed.
You can find a detailed discussion on What happened under the hood in the discussion ChromeDriver showing Lost UI Shared Context
So as a first step you need to remove the argument: '--disable-gpu'
flaky tests
You seem to be executing your tests with the argument --window-size=800,600 which implies a reduced Viewport.
In order to utilize the maximum possible Viewport you must initialize the Chrome Browser in maximized mode through the argument: 'start-maximized'
angular
From Angular perspective, you can avoid timeouts by using the proper expected_conditions. You can find a detailed discussion about different expected_conditions in WebDriverWait not working as expected
--headless
Finally, I am not sure what exactly you meant as in ...my tests fail to run when I attempt to use the headless option, without the chrome options set.... Perhaps the argument '--headless' can be invoked only through chromeOptions and no other alternative.
I have the same error while running [1010/161441.019:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
but my test runs perfect.I have you referred this https://gist.github.com/cvuorinen/543c6f72f8ec917ebfd596802d387aa3
I hope this below may help you
https://cvuorinen.net/2017/05/running-angular-tests-in-headless-chrome/
https://developers.google.com/web/updates/2017/04/headless-chrome

The constructor FirefoxDriver(FirefoxOptions) is undefined

I am using Selenium 3.5.3 and following is my code.
I am trying to use Firefox options in the constructor as in
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/firefox/FirefoxDriver.html#FirefoxDriver-org.openqa.selenium.firefox.FirefoxOptions-
FirefoxOptions options=new FirefoxOptions();
options.setProfile(profile);
driver =new FirefoxDriver(options);
I am getting an error in instantiating the Firefox driver:
The constructor FirefoxDriver(FirefoxOptions) is undefined
How can I solve this?
Firefox version 55.0.3 64 bit
Geckodriver v0.18.0
Try this code:
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
public class FirefoxOptionsDemo {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "E:\\software and tools\\geckodriver.exe");
FirefoxProfile profile =new FirefoxProfile(new File("C:\\Users\\sys\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\ejtrne37.QAProfile"));
FirefoxOptions option=new FirefoxOptions();
option.setProfile(profile);
// Initialize Firefox driver
WebDriver driver = new FirefoxDriver(option);
//Maximize browser window
driver.manage().window().maximize();
//Go to URL which you want to navigate
driver.get("http://www.google.com");
//Set timeout for 5 seconds so that the page may load properly within that time
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//close firefox browser
driver.close();
}
}
This is the image for your reference:
The issue is due to older selenium version coexisted. mvn clean install resolved the issue.
Your problem may be related to different causes.
The common cause is a misaligned version of your firefox browser and/or gecko driver and/or selenium library.
I solved this problem upgrading gecko driver and selenium library to the latest version.
In my case, mvn clean install does not resolved the problem
Since an upgrade to current available release versions is not a doable action by many since it is not acceptable to their teams due to the impact - so they need a working fix for current in use version itself hence my answer -
I may be answering it a lot late but my solution is a workable one for this problem and I can even explain why it is workable and why above one is not workable as asked in your query -
For older selenium and gecko driver versions, the above suggested method i.e. Options class utilization used to work from Selenium 3.5 and upwards (officially) but for versions lower than 3.5 - the options class was not available, so the above suggested method does not work.
I backtracked and found that even in the most widespread popular Selenium version 3.14(which I ended up using for project specific needs, even though the current stable release is at Selenium 4.5 :D) the options class and above suggested method does not work.
So the alternative is just to replace the import of options class and utilization of any of its methods.
In my code I just used direct paths for geckodriver and firefox exe paths and then instantiated the FirefoxDriver class object via WebDriver interface and the constructor is undefined error stops troubling as it is we are not passing any argument in constructor as expected by Eclipse JVM:
Here are my exact lines of code to solve this -
System.setProperty("webdriver.gecko.driver", "D:\\Selenium Projects\\BrowserDrivers\\geckodriver.exe");
System.setProperty("webdriver.firefox.bin", "C:\\Program Files\\Mozilla Firefox\\firefox.exe" );
driver = new FirefoxDriver();
Rest of the code remains as is originally.
The above method of options class utilization or multiple arguments in constructor are supported only after Selenium 3.6. If you use latest selenium and geckodriver, then I dont think you will run in above problem at all as I was able to see it working in the latest versions.
But sometimes we can't just upgrade to our wishes, and we need a fix in the current used versions itself, hence this solution has been suggested by me.

Qooxdoo - Theme to use is not available

I have an qx v2.0.1 app working off the local file system and it runs fine in Firefox v14, but in Chrome v18 it gives me this error:
Uncaught Error: The theme to use is not available: edd.theme.Theme
qx.Class.define.members.initializeMeta.js:108
qx.Class.define.members.mainAbstractGui.js:82
qx.Class.define.members.baseObject.js:141
qx.Class.define.members.mainApplication.js:38
qx.Class.define.statics.readyBaseInit.js:77
qx.Class.define.members.dispatchEventDirect.js:134
wrappedFunctionInterface.js:451
qx.Class.define.members.dispatchEventManager.js:873
qx.Class.define.statics.fireEventRegistration.js:310
qx.Class.define.members.__fireReadyApplication.js:188
qx.Class.define.statics.onScriptLoadedApplication.js:106
qx.$$loader.signalStartupedd.js:159
qx.$$loader.initUrisedd.js:195
I thought I've come across this before and a ./generate.py distclean fixed it, but not this time. Someone else had a similar bug that was fixed:
http://bugzilla.qooxdoo.org/show_bug.cgi?id=1463
Any ideas?
This question is too tricky, and probably involves things like looking at verbose generator output and your job configs, so it is not really suitable for a Q&A site. I suggest you open up a bug for it at the qooxdoo project.
Interestingly enough, after a computer reboot it started working in chrome again. So the chrome clear browser cache/history everything since the beginning of time must not catch everything. So now it's working again...odd.

Resources