Google Chrome unable to navigate to specified URL when triggered from Selenium - java

I have an automation framework developed around Selenium-WebDriver which launches Chrome and navigates to specified URL and performs specified automation.
When I commissioned the framework to perform a long task and left it overnight to run (Run was not successful). The following day when I tried to re-run a new set of Tests, Selenium was able to fire Chrome but the Browser would not navigate to the specified URL. The following is the detailed stack trace.
Starting ChromeDriver (v2.7.236900) on port 60678
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=41.0.2272.118)
(Driver info: chromedriver=2.7.236900,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.12 seconds
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_25'
Driver info: driver.version: RemoteWebDriver
Session ID: a2fafed66d51994e3ef57bada99fddbf
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:683)
at com.gravitant.utils.Util.launchBrowser(Util.java:1711)
at com.gravitant.test.RunTests.start(RunTests.java:147)
at com.gravitant.test.RunTests.main(RunTests.java:80)
This is the second time I am facing the same issue.
When I tried to google search the error I was able find this particular forum.
I tried to re-download Chrome_driver but it did not help. Restarting the system did not help either. I double checked the code and all the set-up but nothing was changed.
Curiously I was able to stumble upon a curious solution.
Solution - Re-installing Chrome Browser solved the issue. I was able to run the tests perfectly.
I am curious to understand why this was and what might have caused chrome to behave so oddly.

In my case, the chrome browser version and chromedriver versions were incompatible. Chrome updated automatically from 56 to 57 and my chromedriver version was 2.27.
The 2 issues throwing 'org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension' error (when maximizing the browser and when taking screenshots), where fixed after updating to cromdriver version 2.28.

The issue here is, Selenium-WebDriver is unable to launch the installed 3rd Party Extensions in chrome.
I encountered the issue today as well, so instead of re-installing google chrome, I deleted all the extensions I had installed on Chrome. I have a couple of "Add Blocker" extensions installed.

Reason for the exception is chrome failed to load selenium automation extension.
When ever selenium opens chrome browser, selenium loads a chrome extension in chrome browser to work with it from some temp location. If chrome browser failed to load that extension it will throw an exception.
I got the same exception when my organization blocked loading third party extensions in my chrome browser.
Test method
Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress_John threw exception:
System.InvalidOperationException: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome- extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=41.0.2272.118)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
I am using Selenium with C# and Visual Studio.

I was facing the same issue, In my case the main problem was:
Incompatibility between chrome version and chromedriver version.
Chrome browser is self upgraded, it updates to latest version automatically (In most of case).
So you need to upgrade chromedriver version periodically and there are release notes are also available which describes the compability between chromedriver and chrome version.

I had this on my Windows 10 (64 bit) PC after upgrading to Selenium 3.3.1. Downloading Chromedriver 2.29 and overwriting the old version worked. See - https://chromedriver.storage.googleapis.com/index.html?path=2.29/

In case someone is still looking for an answer. Here is the matching response for my situation.
https://github.com/SeleniumHQ/selenium/issues/3508
This exactly what is happening in my case where, I'm getting it 60-70% of the time when maximize is called
org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:945)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWindow.maximize(EventFiringWebDriver.java:644)
at org.openqa.selenium.remote.server.handler.MaximizeWindow.call(MaximizeWindow.java:30)
at org.openqa.selenium.remote.server.handler.MaximizeWindow.call(MaximizeWindow.java:1)

I found this problem is chromedriver version cause. My case run ok when i update the chromedriver.

Related

Exception occurred at =: unknown error: call function result missing 'value' using Selenium Python and ChromeDriver

I am a new software developer, and have been asked to edit some scripting test written with Cucumber, but the code is throwing an exception that my team does not recognize.
Exception occurred at =: unknown error: call function result missing 'value'
(Session info: chrome=103.0.5060.134)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.19042 x86_64) (WARNING: The server did not provide any stacktrace information)
I am not sure what I am allowed to share but this s the exception that is being thrown. I heard that it could have something to do with the Chrome Driver, but I am not sure how possible it is to update them (I would need to submit a ticket and get the update approved). Has anyone experienced this issue before, and have you had luck finding a solution?
A quick side note. The issue is only happening with my system. The other person working on this with me is not experiencing any issues.
This error message...
Exception occurred at =: unknown error: call function result missing 'value'
(Session info: chrome=103.0.5060.134)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.19042 x86_64) (WARNING: The server did not provide any stacktrace information)
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chrome=103.0
But you are using chromedriver=2.29
which is old and ancient.
So there is a clear mismatch between chrome=103.0 and the chromedriver=2.29
Solution
Ensure that:
Selenium is upgraded to current released Version 4.3.0.
ChromeDriver is updated to current ChromeDriver v103.0 level.
Chrome Browser is updated to current chrome=103.0 (as per chromedriver=103.0.5060.53 release notes).

Chrome version must be between 71 and 75 error after updating to ChromeDriver 2.46

After update of chromedriver to version 2.46 my tasts fail to initialize.
I got message like this:
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 44269
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Failed to invoke configuration method com.personal.CustomTest.initTests not created: Chrome version must be between 71 and 75
(Driver info: chromedriver=2.46.628402,platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.58 seconds
Build info: version: '2.53.1'
It is clearly saying that my browser version is not valid. But I am using Chrome 72.0.3626.119 so it is between 71 and 75.
Selenium version is 2.53.1.
And I am running test through console command with the help of testNG.
Any idea? Every ideas that I found was about changing selenium version but I cant do it.
For me to resolve this problem :
On Windows
cd C:\Users\[myname]\AppData\Roaming\npm\node_modules\protractor
npm i webdriver-manager#latest
webdriver-manager update
webdriver-manager start &
On Cent-OS (I used Cent-OS 7.4.* and it worked fine.)
cd /usr/lib/node_modules/protractor/
sudo npm i webdriver-manager#latest
sudo webdriver-manager update
sudo webdriver-manager start &
I hope this helps you in any way.
This error message...
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 44269
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Failed to invoke configuration method com.personal.CustomTest.initTests not created: Chrome version must be between 71 and 75
...implies that the ChromeDriver v2.46 is not compatible with the Chrome Browser version which is being accessed by your program/webdriver.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.46
Release Notes of chromedriver=2.46 clearly mentions the following :
Supports Chrome v71-73
Though you mentioned you are using Chrome 72.0.3626.119 possibly there are multiple instances of Chrome Browser installed within your system and your program by default is accessing the Chrome Browser whose version is not between v71.x and v75.x
You are using chrome=67.0
Release Notes of ChromeDriver v2.38 clearly mentions the following :
Supports Chrome v65-67
Solution
Keep JDK upgraded to recent levels JDK 8u201.
Uninstall all the instances of Chrome Browser (you can opt to use Revo Uninstaller).
Upgrade ChromeDriver to current ChromeDriver v2.46 level.
Keep Chrome version between Chrome v71-73 levels. (as per ChromeDriver v2.46 release notes)
For me, I had to update my chrome driver in my project to match the version of Chrome on my local machine.
yarn add chromedriver#76.0.0 -D
https://www.npmjs.com/package/chromedriver
In my case I was getting the same error after my chrome was updated to version 76. Which was happening when chimp tries to use chromedriver to execute the selenium test.
DevTools listening on ws://127.0.0.1:49220/devtools/browser/e88586cb-ed67-44fc-a742-43b767e2b8f9
[chimp][helper] setupBrowserAndDDP had error
{ Error: session not created: Chrome version must be between 71 and 75
at Object.wait (C:\ACPMS\ELS_AT\node_modules\fibers\future.js:449:15)
at Object.<anonymous> (C:\ACPMS\ELS_AT\node_modules\wdio-sync\build\index.js:344:27)
at Object.<anonymous> (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\session-manager.js:145:21)
at initBrowser (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\chimp-helper.js:189:43)
at Object.setupBrowserAndDDP (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\chimp-helper.js:264:7)
at Context.<anonymous> (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\mocha\mocha-helper.js:13:15)
at C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\utils\fiberize.js:29:22
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)
at new RuntimeError (C:\ACPMS\ELS_AT\node_modules\webdriverio\build\lib\utils\ErrorHandler.js:143:12)
at Request._callback (C:\ACPMS\ELS_AT\node_modules\webdriverio\build\lib\utils\RequestHandler.js:318:39)
at Request.self.callback (C:\ACPMS\ELS_AT\node_modules\request\request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (C:\ACPMS\ELS_AT\node_modules\request\request.js:1161:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous>
For me it didn't work when I updated the chrome driver by npm (both globally and locally) and then I followed these steps to resolve the issue, which might give some idea on where to check in this kind a issue:
Because exception was thrown in node_modules\chimp\dist\lib\utils\fiberize.js i navigated to that file and found one level above this file node_modules\chimp\dist\lib\chromedriver.js which has the code to start chromedriver.
I added a console.log to chromedriverPath which can be seen below and re-executed the tests to get the chromedriver path in console logs.
Chromedriver.prototype.start = function(callback) {
var self = this;
var port = self.options.port;
if (this.child) {
callback();
return;
}
var chromedriverPath = chromedriver.path;
//this was added my me the see that chrome drive path
console.log("[chimp] " + chromedriverPath);
if (fs.existsSync(chromedriverPath)) {
this.child = processHelper.start(
{
bin: chromedriverPath,
prefix: "chromedriver",
args: ["--port=" + port, "--url-base=wd/hub"],
waitForMessage: /Starting ChromeDriver/,
errorMessage: /Error/
},
callback
);
} else {
callback("[chimp][chromedriver] Chromedriver executable not found.");
}
};
When i got the path of the chromedriver which is used to execute the tests, i just navigated to that folder and replaced chromedriver executable with the most recent version.
I hope this helps.
Try this: Download the compatible ChromeDriver.exe file for the updated version of Chrome browser and replace it. It works for me.

EDGE crashes with webDriver

I’m using,
◦Selenium 3.12.0
◦Java binding
◦Windows 10 (build 15063.1029)
◦EDGE driver (Version: 4.15063 | Edge version supported: 15.15063 )
Here is my code to open the browser
import org.openqa.selenium.edge.EdgeDriver;
System.setProperty(“webdriver.edge.driver", C://mE//Selenium//Installation//Drivers//Edge//v15063//MicrosoftWebDriver.exe”);
WebDriver driver = new EdgeDriver();
The browser (EDGE) opens for a sec and then crashes immediately. Here is the error (unknown),
Exception in thread “main” org.openqa.selenium.WebDriverException: Unable to parse remote response: Unknown error Build info: version: '3.11.0’, revision: 'e59cfb3’, time: ‘2018-03-11T20:33:08.638Z’ os.name: 'Windows 10’, os.version: '10.0’, java.version: ‘10.0.1’ Driver info: driver.version: EdgeDriver at
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:111) at
org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73) at
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) at
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545) at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209) at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:132) at
org.openqa.selenium.edge.EdgeDriver.(EdgeDriver.java:141) at
org.openqa.selenium.edge.EdgeDriver.(EdgeDriver.java:96) at
projectOne.classOne.main(classOne.java:66)
This only happens with EDGE. Other browsers (IE, Chrome & FireFox) are launching just fine. I realize that, there is a limitation that EDGE allows only one instance to be running for webDriver testing. In my case, there was no other instance of EDGE running and yet it was crashing soon after it launched. I'm wondering is there any settings changes need to be made in EDGE in order for it to work with webDriver.
There shouldn't be any other settings you need to make this work.
Sometimes this can not work if MicrosoftWebDriver.exe is stuck in a zombie-type state. So check your task manager that this isn't the case.
Your MicrosoftWebDriver.exe seems to match your windows version, but it might be worth just going to https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ to just download a fresh copy to ensure there's nothing funky going on there.
Something else to try, try launching edge via this code:
var edgeService = EdgeDriverService.CreateDefaultService();
edgeService.UseVerboseLogging = true;
var edgeOptions = new EdgeOptions();
driver = new EdgeDriver(edgeService, edgeOptions);
You might be able to get more logging out of this too.
Could be below reason
Download the Webdriver as per the OS Build Version
Check the Edge browser opening only one tab on manually opening the browser
it should have only one URL in the Browser settings --> open Microsoft edge with
Edge by dafault runs on instance to make the page load faster. This is the default setting in Windows 10. So even if we close edge one instance is always running. We can disable it.
Follow the steps here:
https://www.askvg.com/windows-10-what-are-microsoft-edge-exe-processes-running-in-task-manager-and-how-to-disable-them/
For me the following fix worked:
Go to WebDriver.
Install Microsoft Edge Driver according to the version of edge browser(You can go to this page to have reference: Use WebDriver (Chromium) for test automation).
Go to downloads and unzip the driver.
Now you can write the following code in selenium in java.
System.setProperty("webdriver.edge.driver", "C:\\Users\\User-name\\Downloads\\msedgedriver.exe");
driver = new EdgeDriver();
Please heck your browser version and then pick the right one from the below link ,
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads
This is working fine for me and i too faced the similar problem.

Mac + Selenium + Chrome = cannot find Chrome binary

Hi i m trying to setup selenium with eclipse on a Mac pc.
When I download the ChromeDriver and place it on the below folder :
System.setProperty("webdriver.chrome.driver","/Users/george/Downloads/chromedriver");
WebDriver driver = new ChromeDriver();
I run the code.
Then I get the following exception :
Starting ChromeDriver 2.21.371459
(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 33424 Only local
connections are allowed. Exception in thread "main"
org.openqa.selenium.WebDriverException: unknown error: cannot find
Chrome binary (Driver info: chromedriver=2.21.371459
(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.10.5
x86_64) (WARNING: The server did not provide any stacktrace
information) Command duration or timeout: 312 milliseconds Build info:
version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'Georges-Mac-mini.local', ip: '192.168.1.2',
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5',
java.version: '1.7.0_25' Driver info:
org.openqa.selenium.chrome.ChromeDriver
So I m assuming that some binary is missing? Note that I use regularly Chrome as my browser.. I dont know if this is related or not.
My pc is mac. I have read the ChromeDriver site but I dont understand what exactly to do. I have problems navigating to paths that are a bit strange like : "Google Drive" instead of "Google/Drive" or paths like
"cd Chrome\ Apps.localized/" or "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome". I mean , wt?? are those back and forth slashes ??? I just now a few things on linux but here.. i m stuck and confused
On Windows things where much easier.. you just downloaded an .exe file locally point the driver with options to that file and everything was smoothly. I cant find information on mac specific.
Can anyone help ?
Thanks
"cannot find Chrome binary" simply means the os cannot find chrome app. Just check chrome installation directory. Right directory should be "/Applications/Google Chrome.app". If you download your chrome from third platform, the directory may be "/Applications/Chrome.app". It makes the os cannot find your chrome.
The stack trace indicates that it cannot find the binary for the chrome webdrive. You'll need to download it if you haven't already. Once you have downloaded the chrome webdriver, point your application at the binary.
if you have a path with spaces, such as
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
you'll need to escape the spaces with backslashes like so
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
a backslash followed by a space, \, tells the argument parser not to use that space as a delimiter but rather to include it as part of the path.
Aside from trying the path with and without slashes (the ruby driver expects spaces not be escaped), this problem may also be caused by a version mismatch between Chrome and Chromedriver.
Chrome Canary, specifically, is often unsupported by the current stable Chromedriver release. There are nightly builds linked at https://sites.google.com/a/chromium.org/chromedriver/chromedriver-canary. Enter the proper prefix in the search box for the Mac version, then scroll as far as it goes for the most recent version–yeah, the interface sucks.
There's a decent chance this won't work, either. Installing the stable Chrome release is your best bet.
I was facing this "cannot find Chrome binary", when I realised that I don't have the Chrome Browser installed before to try to use it.
Don't do this at home, guys...
I found that upgrading selenium-webdriver to 3.142.3 and Capybara to 3.20.2 fixed this for me. This required making some changes to my webdriver configuration:
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions': {
args: %w(--disable-gpu --headless --no-sandbox --window-size=1024,768)
}
)
driver = Capybara::Selenium::Driver.new app, {
browser: :chrome,
desired_capabilities: capabilities,
http_client: client,
}
Use double slashes in your path like this:
//Test Data//Drivers//chromedriver
and copy and paste the chrome driver exe to some other location.

Selenium + Jenkins: Missing location header

I am trying to use Selenium Grid with Jenkins.
When I start Selenium Hub and Node with the server-standalone 2.35.0 jar, everything works perfect.
However, does not work when I use the Jenkins Selenium Grid Plugin as hub.
The Error appears here:
driver = new RemoteWebDriver ( new URL ( gridURL ), capabilities );
grid URL is "http://localhost:4444/wd/hub"
capabilities is this:
DesiredCapabilities capabilities = DesiredCapabilities.firefox ();
capabilities.setPlatform ( Platform.LINUX );
This exception is thrown:
org.openqa.selenium.WebDriverException: Error forwarding the new session new session request for webdriver should contain a location header with the session.
Command duration or timeout: 25.28 seconds
Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.8.0-31-generic', java.version: '1.7.0_40'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
As Hub I use the Jenkins Selenium Plugin Version 2.3
As Node I use selenium-server-standalone-2.35.0.jar.
When I open http://localhost:4444/ with a browser, it says: You are using grid 2.29.0
So I downloaded selenium-server-standalone-2.29.0.jar and let it run as a hub. The node still is Version 2.35.0.
Then I've got the same exception. I tried node and hub with 2.29.0 but it seems that my Firefox is too new for this.
I searched several hours but didn't find anything regarding this error.
Edit:
The Plugin, which is installed by Jenkins, is from August, 18th 2013: https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin
The developer updated the plugin two days later on August, 20th 2013: https://github.com/jenkinsci/selenium-plugin/commit/316eccdef608e855863cf04b1c240fa2c7b8b762
I don't know if this is causing my errors, but it is possible. I don't know yet how to do this, but I'm going to try to build my own plugin version from the source code on github.
I now know definitely what the problem is:
As I mentioned above the node is Selenium Version 2.35. The current Jenkins Selenium Plugin is Version 2.3 which uses Selenium 2.29. This is causing the error.
Now I used Selenium Version 2.29 as node. And installed Firefox Version 18. Now everything is working fine. I contacted the developer and I am trying to build the current Plugin Version from git. For now without success, but I think I'll open another thread for this.
Thank you for your help.
You can update the selenium version in the jenkins plugin, replace 2.29.0 with 2.39.0 in the below mentioned path:
[JenkinsFolder]\plugins\selenium\WEB-INF\lib
You will find the old jar here. replace it with the latest jar.
It will work fine.
This error means that you have no nodes connected to the hub. The Hub is UP and receiving connections, but is unable to forward the request to a node.
Make sure that you have nodes connected to your hub. You can do this by --
java -jar selenium-server-2.29.0.jar -role node -hubUrl http://ip-of-hub:4444/wd/register
This command may be inaccurate. Consult the official doc.

Categories