Behat + Mink - Selenium2 issue: 'requiredCapabilities' parameter is not an object - selenium

I am running tests using Behat, Mink and Selenium2.
I am running the example search-with-autocompletion test that employs the #javascript tag in a scenario.
This is the exception I get:
Behat\MinkExtension\Context\MinkContext::visit()
'requiredCapabilities' parameter is not an object
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: '73b4ecff4d3d', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-32-generic', java.version: '1.8.0_131'
Driver info: driver.version: unknown
remote stacktrace: stack backtrace:
0: 0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d
1: 0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0
2: 0x5068af - <webdriver::capabilities::LegacyNewSessionParameters as webdriver::command::Parameters>::from_json::hd98a6246b0731ef9
3: 0x506e44 - <webdriver::command::NewSessionParameters as webdriver::command::Parameters>::from_json::ha19e8e984af08954
4: 0x41f249 - <webdriver::command::WebDriverMessage<U>>::from_http::h239258e4ad67ac76
5: 0x43a64e - <webdriver::server::HttpHandler<U> as hyper::server::Handler>::handle::hd20f6e9e0a69e2b4
6: 0x42c9af - hyper::server::listener::spawn_with::{{closure}}::h8fa3cf343f537777
7: 0x4092d7 - std::panicking::try::do_call::h649be53a713433eb
8: 0x5dc20a - panic_unwind::__rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:98
9: 0x41c43e - <F as alloc::boxed::FnBox<A>>::call_box::hf41feb3b2b67541e
10: 0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>
at /checkout/src/liballoc/boxed.rs:650
- std::sys_common::thread::start_thread
at /checkout/src/libstd/sys_common/thread.rs:21
- std::sys::imp::thread::{{impl}}::new::thread_start
at /checkout/src/libstd/sys/unix/thread.rs:84
I am running Selenium2 standalone server v3.5.3 using docker-selenium and geckodriver v0.18.
My configuration for Behat:
default:
context:
class: 'FeatureContext'
extensions:
Behat\MinkExtension\Extension:
base_url: '<skipped>'
goutte:
guzzle_parameters:
curl.options:
CURLOPT_SSL_VERIFYPEER: false
CURLOPT_CERTINFO: false
CURLOPT_TIMEOUT: 120
ssl.certificate_authority: false
selenium2:
wd_host: "http://127.0.0.1:4444/wd/hub"
capabilities:
browser: firefox
# acceptSslCerts: true
# marionette: true
# No context:
no_context:
paths:
bootstrap: 'NON_EXISTING_FOLDER'
filters:
tags: '~#javascript'
# Context based on inheritance:
inheritance:
context:
class: 'InheritedFeatureContext'
# Context based on traits:
traits:
paths:
bootstrap: 'features/php54_bootstrap'
context:
class: 'TraitedFeatureContext'
# Context based on subcontexting:
subcontexts:
context:
class: 'SubcontextedFeatureContext'
If connecting to localhost:4444 I am able to create a session by hand.
If using python-selenium I am able to run this code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX
)
#driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Thank you in advance folks.

Selenium 2 and Selenium 3 are not same. They are not 100% compatible. Selenium 3 is a step towards the W3C standard for Selenium.
From the exception it seems that Mink may not be compatible with Selenium 3. So either downgrade your Python selenium version to 2 (that again may not work because latest browsers may support only 3)
Also please look at https://github.com/minkphp/MinkSelenium2Driver/issues/254

Related

Selenium: Using a Chrome Profile for Remote Webdriver: unknown error: cannot create default profile directory

Using ChromeDriver v102 (since there's a current bug open for v103 https://bugs.chromium.org/p/chromedriver/issues/detail?id=4121)
I get the error (full log information listed below):
Response code 500. Message: unknown error: cannot create default profile directory
when I run ChromeDriver remotely on the selenium node grid.
I am able to use a specific chrome profile when running the ChromeDriver locally. The driver for Firefox also works remotely, so I have to conclude that this is a "remote ChromeDriver" issue.
I download the chrome profile from the cloud into my current working directory. The directory is detected/located in my code.
There are no spaces in my path to the profile directory. The chrome profile only contains essential files I want to keep.
save_file_list = ["Bookmarks", "History", "History-journal", "Cookies", "Cookies-Journal", "Favicons", "Favicons-journal"]
When I use the ChromeDriver locally, I download the chrome profile, it loads the essential files and the driver creates the rest on its own. The same code works (and runs in an executable) when I run it on windows and mac machines.
However, this fails to work at all when using the remote driver. The remote driver works perfectly when I do not use a specific user-data-dir. It even works using an authenticated proxy. Therefore there are no issues with my connection. The code fails in both cases: when I use a virtual environment to run the code and when I run a docker image. Therefore I know it's not a docker issue.
This is the code for loading a chrome profile to my chrome options:
def add_profile(self, chrome_options):
if self.download_profile():
arg = f'--user-data-dir={os.getcwd()}/{self.profile_path}'
logging.info(f'Adding arg: {arg}')
chrome_options.add_argument(arg)
logging.info("Successfully added profile to chrome driver.")
return chrome_options
def setup_chrome(self) -> webdriver.Remote:
prefs = {
"credentials_enable_service": False,
"profile.password_manager_enabled": False,
}
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--enable-javascript")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option("prefs", prefs)
chrome_options = self.proxy.add_proxy_plugin(chrome_options, use_proxy=True)
chrome_options = self.chrome_profile.add_profile(chrome_options) #currently not working
capabilities = {
"browserName": "chrome",
"chromeOptions": {
"useAutomationExtension": False,
"forceDevToolsScreenshot": True,
"args": ["--start-maximized", "--disable-infobars"],
},
}
remote_driver_host = os.environ.get("SELENIUM_URL")
logging.info("Setting up remote connection")
try:
selenium_connection = RemoteConnectionV2(
remote_driver_host, keep_alive=False
)
selenium_connection.set_remote_connection_authentication_headers()
driver = webdriver.Remote(
command_executor=selenium_connection, # for prod
# command_executor="http://localhost:4444/wd/hub", # for local development
desired_capabilities=capabilities,
options=chrome_options,
keep_alive=True,
)
logging.info("SUCCESS: created remote chrome using connection")
except Exception as ex:
logging.error(f"Failed to initiate Chrome browser: {ex}")
raise
try:
driver.get("https://www.google.com")
except Exception as e:
logging.error(f"Failed to connect using proxy: {e}")
return driver
This is the log:
27-Jun-22 10:04:53 AM EDT | INFO | SUCCESS: downloaded proxy assignment:
27-Jun-22 10:04:54 AM EDT | INFO | Successfully downloaded & extracted _zGF_23_CHROME_PROFILE.
27-Jun-22 10:04:54 AM EDT | INFO | Adding arg: --user-data-dir=/Users/<myuser>/Repos<my-repo>/_zGF_23_CHROME_PROFILE
27-Jun-22 10:04:54 AM EDT | INFO | Successfully added profile to chrome driver.
27-Jun-22 10:04:54 AM EDT | INFO | Setting up remote connection
[Authentication] No identity token was found in the environment. Requesting a new one.
[Authentication] An identity token found successfully.
27-Jun-22 10:04:55 AM EDT | ERROR | Failed to initiate Chrome browser: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: cannot create default profile directory
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '11.0.15'
Driver info: driver.version: unknown
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '11.0.15'
Driver info: driver.version: unknown
Stacktrace:
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:194)
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:67)
at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:145)
at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:362)
at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:618)
at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:544)
at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:791)
at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:752)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
at java.lang.Thread.run (Thread.java:829)
27-Jun-22 10:04:55 AM EDT | ERROR | Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: cannot create default profile directory
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '11.0.15'
Driver info: driver.version: unknown
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '11.0.15'
Driver info: driver.version: unknown
Stacktrace:
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:194)
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:67)
at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:145)
at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:362)
at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:618)
at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:544)
at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:791)
at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:752)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
at java.lang.Thread.run (Thread.java:829)

Running headless Firefox with Selenium on OpenShift - Connection refused

So I have setup some Selenium tests to run on OpenShift on headless Chrome + Firefox. They run fine on my Windows machine on a browser with GUI, and Chrome headless also works fine.
For Firefox I get the error message "connection refused" and geckodriver doesnt seem to be able to connect to Firefox.
I found a dozen of posts about this matter, but no solution so far.
Anyone got any advice on this?
thanks a lot!
Desired Capabilities
public static DesiredCapabilities getFirefoxCapabilities () {
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setPlatform(org.openqa.selenium.Platform.ANY);
FirefoxOptions options = new FirefoxOptions();
options.setBinary("/usr/lib64/firefox/firefox-bin");
options.setHeadless(true);
options.addArguments("--disable-gpu");
options.addArguments("--allow-insecure-localhost");
options.addArguments("--remote-debugging-port=9222");
options.setAcceptInsecureCerts(true);
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("sanity-test.running", true);
options.setProfile(profile);
caps.merge(options);
return caps;
}
Setup of Webdriver implementation
System.setProperty("webdriver.gecko.driver", openshift_browserDriverPath_Firefox);
try {
driver.set(new FirefoxDriver(headlessDriverCapabilityFactory.getCapabilities(getBrowserName())));
}
catch(Exception e) {
System.out.println("setup headless ff: " + e.getMessage() + "failed at " + e.getStackTrace());
}
Excerpt from Jenkins Log
1565697695283 mozrunner::runner INFO Running command:
"/usr/lib64/firefox/firefox-bin" "-marionette" "-headless" "--disable-
gpu" "--allow-insecure-localhost" "--remote-debugging-port=9222" "-
foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.LMzPtqcIh6wS"
*** You are running in headless mode.
1565697700885 addons.xpi WARN Can't get modified time of
/usr/lib64/firefox/browser/features/aushelper#mozilla.org.xpi
1565697701079 addons.xpi-utils WARN addMetadata: Add-on
aushelper#mozilla.org is invalid: [Exception... "Component returned
failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)
[nsIFile.isFile]" nsresult: "0x80520006
(NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)" location: "JS frame ::
resource://gre/modules/addons/XPIInstall.jsm :: loadManifestFromFile ::
line 925" data: no] Stack trace:
loadManifestFromFile()#resource://gre/modules/addons/XPIInstall.jsm:925 syncLoadManifestFromFile()#resource://gre/modules/addons/XPIProvider.jsm:940
addMetadata()#resource://gre/modules/addons/XPIProvider.jsm ->
resource://gre/modules/addons/XPIProviderUtils.js:1173
processFileChanges()#resource://gre/modules/addons/XPIProvider.jsm ->
resource://gre/modules/addons/XPIProviderUtils.js:1529
checkForChanges()#resource://gre/modules/addons/XPIProvider.jsm:3304
startup()#resource://gre/modules/addons/XPIProvider.jsm:2196
callProvider()#resource://gre/modules/AddonManager.jsm:253
_startProvider()#resource://gre/modules/AddonManager.jsm:728
startup()#resource://gre/modules/AddonManager.jsm:892
startup()#resource://gre/modules/AddonManager.jsm:298 observe()#jar:file:///usr/lib64/firefox/omni.ja!/components/addonManager.js
:63
1565697701094 addons.xpi-utils WARN Could not uninstall invalid
item from locked install location
Aug 13, 2019 12:01:44 PM org.openqa.selenium.remote.ProtocolHandshake
createSession
INFO: Detected dialect: W3C
#Test - internal test: Chrome browser headless
Aug 13, 2019 12:01:46 PM cucumber.runtime.java.ObjectFactoryLoader
loadSingleObjectFactory
WARNING: Use deprecated reflections to load ObjectFactory.
setup headless ff: connection refused
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-
14T08:17:03'
System info: host: 'ifx-java-slave-browsers.latest-6llvz', ip:
'10.125.24.3', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-
862.el7.x86_64', java.version: '1.8.0_222'
Driver info: driver.version: FirefoxDriver
#Daniel Davison's article on OpenShift Templates for Selenium can provide you with all the steps required to leverage openshift with Selenium within Docker containers in creating a scale-able framework for Selenium.
Here are the required links:
Configuration for Selenium Hub
Configuration for Selenium Node - Chrome
Configuration for Selenium Node - Firefox

'UnknownError',message: 'An unknown server-side error occurred while processing the command.',orgStatusMessage: 'connection refused with webdriver.io

I am following this guide: http://webdriver.io/guide.html and firefox version I am using 62.0
I followed following steps:
I downloaded latest selenium-standalone-server version 3.14.
I have downloaded latest gecko driver version 0.22.0 and extracted it in project folder
Ran selenium standalone version using command java -jar -Dwebdriver.gecko.driver=./geckodriver selenium-server-standalone-3.5.3.jar
Then run the command npm install webdriverio
Created a test file test.js with code
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'firefox'
}
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end()
.catch(function(err) {
console.log(err);
});
node test.js
instead of getting output "Title was: Google"
i get error
{ Error: An unknown server-side error occurred while processing the command.
at end() - test.js:15:6
details: undefined,
message: 'connection refused\nBuild info: version: \'3.4.0\', revision: \'unknown\', time: \'unknown\'\nSystem info: host: \'RITESHs-MacBook-Pro.local\', ip: \'192.168.1.2\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.6\', java.version: \'1.8.0_171\'\nDriver info: driver.version: FirefoxDriver\nremote stacktrace: stack backtrace:\n 0: 0x10b43d49e - backtrace::backtrace::trace::h3ab5720c483fe461\n 1: 0x10b43d4dc - backtrace::capture::Backtrace::new::h096accf58447e0d5\n 2: 0x10b376534 - webdriver::error::WebDriverError::new::hc0958d01acda7bfc\n 3: 0x10b37d300 - geckodriver::marionette::MarionetteHandler::create_connection::h59a68c8dfef48e54\n 4: 0x10b35cd3c - _$LT$webdriver..server..Dispatcher$LT$T$C$$u20$U$GT$$GT$::run::h5a26ba0bb4fdb139\n 5: 0x10b3350c5 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3f868f7a1a12bdcc\n 6: 0x10b33fd2d - std::panicking::try::do_call::hfce1ad2a948c3632\n 7: 0x10b4e9a5c - __rust_maybe_catch_panic\n 8: 0x10b352eb5 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h651dedb755194a8c\n 9: 0x10b4e5c4b - std::sys::imp::thread::Thread::new::thread_start::h48c72bb09587cbc3\n 10: 0x7fff515f0660 - _pthread_body\n 11: 0x7fff515f050c- _pthread_start',
type: 'RuntimeError',
seleniumStack:
{ type: 'UnknownError',
message: 'An unknown server-side error occurred while processing the command.',
orgStatusMessage: 'connection refused\nBuild info: version: \'3.4.0\', revision: \'unknown\', time: \'unknown\'\nSystem info: host: \'RITESHs-MacBook-Pro.local\', ip: \'192.168.1.2\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.6\', java.version: \'1.8.0_171\'\nDriver info: driver.version: FirefoxDriver\nremote stacktrace: stack backtrace:\n 0: 0x10b43d49e - backtrace::backtrace::trace::h3ab5720c483fe461\n 1: 0x10b43d4dc - backtrace::capture::Backtrace::new::h096accf58447e0d5\n2: 0x10b376534 - webdriver::error::WebDriverError::new::hc0958d01acda7bfc\n 3: 0x10b37d300 - geckodriver::marionette::MarionetteHandler::create_connection::h59a68c8dfef48e54\n 4: 0x10b35cd3c - _$LT$webdriver..server..Dispatcher$LT$T$C$$u20$U$GT$$GT$::run::h5a26ba0bb4fdb139\n 5: 0x10b3350c5 - std::sys_common::backtrace::__rust_begin_short_backtrace::h3f868f7a1a12bdcc\n 6: 0x10b33fd2d - std::panicking::try::do_call::hfce1ad2a948c3632\n 7: 0x10b4e9a5c - __rust_maybe_catch_panic\n 8: 0x10b352eb5 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h651dedb755194a8c\n 9: 0x10b4e5c4b - std::sys::imp::thread::Thread::new::thread_start::h48c72bb09587cbc3\n 10: 0x7fff515f0660 - _pthread_body\n 11: 0x7fff515f050c - _pthread_start' } }
can anyone please guideline how to resolve this error ??
Seems there is a bit of messup. You have mentioned:
Downloaded latest selenium-standalone-server version 3.14
Command
java -jar -Dwebdriver.gecko.driver=./geckodriver selenium-server-standalone-3.5.3.jar
observe the versioning ^^^ info
Log messages reflect:
Build info: version: \'3.4.0\'
Solution
Upgrade Selenium to current levels Version 3.14.0.
Upgrade GeckoDriver to GeckoDriver v0.22.0 level.
Upgrade Firefox version to Firefox v62.0 levels.
Execute your test

Selenium + Mink + Chrome: "Could not open connection" error

I'm not new to setting up Selenium and Mink, but it always seems to be a hassle. This time I'm trying to get it set up in an ubuntu docker container and I am running into the following error:
Could not open connection: Unable to create new service: ChromeDriverService
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'a75b4026b8e5', ip: '172.20.0.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.60-linuxkit-aufs', java.version: '1.8.0_161'
Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
I can tell that Mink is hitting the Selenium to some degree, since the Selenium server outputs the following immediately before Behat reports the above error:
2018-01-30 16:13:49.870:INFO:osjshC.ROOT:qtp1156060786-12: org.openqa.selenium.remote.server.WebDriverServlet-10bbd20a: Initialising WebDriverServlet
16:13:49.988 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#4b4945b7
16:13:50.006 INFO - /session: Executing POST on /session (handler: BeginSession)
16:13:50.168 INFO - Capabilities are: Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]}
16:13:50.171 INFO - Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
16:13:50.302 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#5a608e4b
16:13:50.303 INFO - /session: Executing POST on /session (handler: BeginSession)
16:13:50.306 INFO - Capabilities are: Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]}
16:13:50.307 INFO - Capabilities {browser: chrome, browserName: chrome, ignoreZoomSetting: false, marionette: true, name: Behat feature suite, tags: [a75b4026b8e5, PHP 5.6.31]} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Any idea what setting I have wrong?
Here's my setup:
Version of the chromedriver I installed:
https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
Version of Chrome I have installed via the apt-get install google-chrome-stable command:
Google Chrome 64.0.3282.119
Java version that's installed:
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
How I started selenium:
xvfb-run --server-args="-screen 0, 1366x768x24" java -Dwebdriver.chrome.driver="usr/bin/chromedriver" -jar selenium-server-standalone-3.8.1.jar &
composer.json:
...
"require-dev": {
"behat/behat": "^3.1",
"behat/mink": "^1.7",
"behat/mink-extension": "^2.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
...
},
behat.yml:
extensions:
Behat\MinkExtension:
goutte: ~
base_url: http://localhost/myapp/
browser_name: chrome
javascript_session: selenium2
default_session: goutte
selenium2:
wd_host: "http://127.0.0.1:4444/wd/hub"
capabilities:
marionette: true
browser: chrome
version: 2.9

WebDriverException: Error: Permission denied to access property "navigator"

Here is the deal with the "magic" encountered: The code works fine on Ubuntu 16.04, Ubuntu 15.10 on a fall with errors:
org.openqa.selenium.WebDriverException: Error: Permission denied to access property "navigator"
org.openqa.selenium.WebDriverException: Error: Permission denied to access property "document"
I have following code:
import geb.spock.GebReportingSpec
import geb.waiting.WaitTimeoutException
class LoginSpec extends GebReportingSpec {
def "#0 go to login FB"() {
when:
browser.go("https://www.facebook.com/")
then:
delay(9)
if (browser.title != "Facebook") {
browser.title == "Facebook - Log In or Sign Up"
browser.currentUrl == "https://www.facebook.com/"
waitFor(30){
$("#loginbutton").size() == 1
}
$("#email").value(Config.FB_USERNAME)
$("#pass").value(Config.FB_PASSWORD)
println("entered credentials")
$("#loginbutton").click()
}
delay(9)
}
void delay(Long seconds){
try {
waitFor(seconds){ }
} catch (WaitTimeoutException ignored){ }
}
}
GebConfig.groovy :
import org.openqa.selenium.firefox.FirefoxDriver
waiting {
timeout = 2
}
environments {
firefox {
driver = { new FirefoxDriver() }
}
}
baseUrl = "https://google.com"
testReportDir = new File("$buildDir/test-reports/UT")
testResultsDir = new File("$buildDir/test-results/UT")
And at build.gradle lines
firefoxTest {
systemProperty "webdriver.gecko.driver", "/usr/bin/geckodriver"
}
Error:
LoginSpec > #0 go to login FB FAILED
org.openqa.selenium.WebDriverException: Error: Permission denied to access property "navigator"
Build info: version: '3.0.0-beta4', revision: '3169782', time: '2016-09-29 10:30:04 -0700'
System info: host: 'tb-buildagent01-infrastructure-ci', ip: '10.4.1.4', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-30-generic', java.version: '1.8.0_66-internal'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20160606114238, version=, platform=LINUX, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, browserVersion=47.0, platformVersion=4.2.0-30-generic, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=Linux, device=desktop}]
Session ID: 5af3ae72-af52-4760-9b9c-5a1261b52113
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:126)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:602)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:284)
at org.openqa.selenium.remote.RemoteWebElement.getAttribute(RemoteWebElement.java:136)
at geb.navigator.NonEmptyNavigator.setInputValue(NonEmptyNavigator.groovy:687)
at geb.navigator.NonEmptyNavigator.setInputValues_closure40(NonEmptyNavigator.groovy:680)
at groovy.lang.Closure.call(Closure.java:414)
at geb.navigator.NonEmptyNavigator.setInputValues(NonEmptyNavigator.groovy:679)
at geb.navigator.NonEmptyNavigator.value(NonEmptyNavigator.groovy:417)
at LoginSpec.#0 go to login FB(LoginSpec.groovy:81)
org.openqa.selenium.WebDriverException: Error: Permission denied to access property "document"
Build info: version: '3.0.0-beta4', revision: '3169782', time: '2016-09-29 10:30:04 -0700'
System info: host: 'tb-buildagent01-infrastructure-ci', ip: '10.4.1.4', os.name: 'Linux', os.arch: 'amd64', os.version: '4.2.0-30-generic', java.version: '1.8.0_66-internal'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20160606114238, version=, platform=LINUX, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, browserVersion=47.0, platformVersion=4.2.0-30-generic, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=Linux, device=desktop}]
Session ID: 5af3ae72-af52-4760-9b9c-5a1261b52113
I understand, that something wrong with environment, but I don't know where I made mistake? Please, give me advice, how can I fix this. Thank you.
In general, the reason was different versions of Ubuntu and Firefox free. If such a mistake to see someone, I recommend to execute "apt-cache policy firefox" from terminal.
On Ubuntu 16.04 now, you can see:
Installed: 49.0+build4-0ubuntu0.16.04.1
Candidate: 49.0+build4-0ubuntu0.16.04.1
Version table:
*** 49.0+build4-0ubuntu0.16.04.1 500
500 http://ua.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
100 /var/lib/dpkg/status
45.0.2+build1-0ubuntu1 500
500 http://ua.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
And on Ubuntu 15.10 :
Candidate: 47.0+build3-0ubuntu0.15.10.1
Version table:
47.0+build3-0ubuntu0.15.10.1 0
500 http://azure.archive.ubuntu.com/ubuntu/ wily-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu/ wily-security/main amd64 Packages
100 /var/lib/dpkg/status
41.0.2+build2-0ubuntu1 0
500 http://azure.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages
And they have to be addressed. And the rollback version of selenium and other dependencies data base can not help, because at the front end may be things that are not supported by the browser (not to speak of the FB), for example: var result = window.Notification.requestPermission(callback) and it is https://developer.mozilla.org/ru/docs/Web/API/Notification/requestPermission :) And yes, you're right it seemed (to view error) that the page is empty - for ajax not work out. On the one hand you may find a bug (not every customer he uses the latest version of the browser), but in my case - this is a plus pain in the ass. And to update the entire system - entertainment for the fan, although it may be in your team has a person who is expressed as procrastination, and in this case, you're in luck.
I was getting the error:
org.openqa.selenium.JavascriptException: Error: Permission denied to access property "navigator"
When I was using Firefox 45.7 and gecko driver
I upgraded Firefox to 52.2, and the error is gone.