Nightwatch vs. self signed certificates - ssl

My nightwatch.js setup for Geckodriver is as follows:
"firefox": {
"launch_url": "...",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
...
"desiredCapabilities": {
"browserName": "gecko",
"marionette": true,
"acceptSslCerts": true
}
}
When running, all tests fail because my certificate is insecure testing on a local installation and enforced ssl. Chromedriver (with basically identical setup) seems to accept the "acceptSslCerts" property and ignores the wrong cert. Geckodriver does not. Is the config wrong or does Nightwatch or Selenium have a problem with "acceptSslCerts"?
I am using the latest version of Geckodriver and Selenium 3.8.1

It looks like the correct capability for the firefox driver is acceptInsecureCerts.
You can see it listed here.

Related

Protractor test broke after enabling local SSL certificate

My Protractor and Typescript based test code is broken, after team install local SSL certificate on the server. Though it able to load the provided URL on browser but still throwing error " Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application."
Based on Protractor-invalid-ssl link have added below snippet in my config but still it throw same error. Have also tried with other options:
acceptSslCerts: true, trustAllSSLCertificates: true, acceptInsecureCerts:true,
ACCEPT_SSL_CERTS:true
But none of the option/arguments work.
/**Browser capabilities */
capabilities: {
browserName: 'chrome',
marionette : true,
acceptInsecureCerts : true
},
Have also tried with firefox still getting same error.
Using Node v8.11.3, chrome 69.0, Protractor 5.4.0, Jasmine 2
When using browser 'chrome', do not set marionette propertie its firefox specific.
You can try with the following capability for chrome:
capabilities: {
browserName: 'chrome',
trustAllSSLCertificates: true,
acceptInsecureCerts: true,
ACCEPT_SSL_CERTS: true,
},

Cannot execute protractor tests using headless chrome on Selenium Grid nodes

I'm using Selenium server 3.8.1, with the hub and 2 nodes.
The hub and each node are executed on different machines.
Currently, I can launch the tests and they're working fine. But, I'm not able to make the headless mode run.
My config JSON only contains the capabilities object.
{
"capabilities":
[{
"browserName": "chrome",
"maxInstances": 3,
"seleniumProtocol": "WebDriver",
"chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1920x1080"]
}}]
}
I launch the selenium nodes using a .bat that contains the following command:
"C:\Program Files\Java\jre1.8.0_181\bin\java" -jar C:\jobs\selenium-node\selenium-server-standalone-3.8.1.jar -role node -hub http://172.16.0.5:5555/grid/register -port 5558 -nodeConfig config.json -maxSession 3
The selenium node works fine and appears on the selenium grid UI. Also, the capabilities of the chrome driver include the --headless and other parameters:
....
capabilities: Capabilities {browserName: chrome, chromeOptions: {args: [--headless, --disable-gpu, --window-size=1920x1080]}, maxInstances: 3, platform: XP, se:CONFIG_UUID: cdc21610-4c47-4d23-9478-a20..., seleniumProtocol: WebDriver}
....
On the protractor.conf file I have these capabilities, that work when I run the tests locally.
seleniumAddress:'http://172.16.0.5:5555/wd/hub',
getPageTimeout: 120000,
allScriptsTimeout: 120000,
ignoreUncaughtExceptions: true,
chromeOnly:true,
directConnect: false,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
"javascriptEnabled": true,
"acceptSslCerts": true,
"browserName": "chrome",
"chromeOptions": {
"args": [ "--headless", "--disable-gpu", "--window-size=1920,1080"]
}
},
But, when I launch the tests, the chrome driver isn't executed on headless mode. Works fine, but the different windows keep appearing.
Environment details:
chromedriver version: 2.36.540470
chrome version: 69.0.3497.100
As per your question/comment update you are using:
chromedriverVersion: '2.36.540470, chrome version' => '69.0.3497.100'
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.36
Release Notes of chromedriver=2.36 clearly mentions the following :
Supports Chrome v63-65
You are using chrome=69.0
Release Notes of ChromeDriver v2.42 clearly mentions the following :
Supports Chrome v68-70
So there is a clear mismatch between the ChromeDriver v2.36 and the Chrome Browser v69.0
Solution
Upgrade Selenium to current levels Version 3.14.0.
Upgrade ChromeDriver to current ChromeDriver v2.42 level.
Keep Chrome version between Chrome v68-70 levels. (as per ChromeDriver v2.42 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.

Error when running Selenium Server via Nightwatch

I'm attempting to run a simple test script. But I receive the following error:
I have my nightwatch config file setup as so:
nightwatch.conf.js
module.exports = {
"src_folders": [
"tests"// Where you are storing your Nightwatch e2e/UAT tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./node_modules/selenium-standalone/.selenium/selenium-server/2.53.1-server.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": { "webdriver.chrome.driver" : "./node_modules/selenium-standalone/.selenium/chromedriver/2.25-x64-chromedriver"
}
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // set to false to test progressive enhancement
}
}
}
}
guinea-pig.js
module.exports = { // addapted from: https://git.io/vodU0
'Guinea Pig Assert Title': function(browser) {
browser
.url('https://saucelabs.com/test/guinea-pig')
.waitForElementVisible('body')
.assert.title('I am a page title - Sauce Labs')
.saveScreenshot('ginea-pig-test.png')
.end();
}
};
The server path and chromedriver path are accurate and the most recent copy. I also have the latest version of chrome installed. Can someone please help me understand what could be the problem? Thanks!
Edit: I've also restarted the whole computer, same issue.
Try using the latest version of the Selenium standalone server v.3.0.1
If that doesn't work, then you can upgrade your chromedriver to the latest version and test. You can find the different versions here:
https://chromedriver.storage.googleapis.com/index.html
Also make sure you are using the most recent version of Nightwatch v0.9.9 and update it in you package.json file.
It is written very clear , your chrome version is lower than what chromedriver needs, just update your chrome to the latest version

Connection refused! Is selenium server started?

I am using Jenkins to run selenium nightwatch tests.
When I run the tests, I get the following error:
Connection refused! Is selenium server started?
I have the following configuration in my nightwatch.json file:
"selenium": {
"start_process": true,
"server_path": "lib/selenium-server-standalone-2.52.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "lib/chromedriver",
"webdriver.ie.driver": "lib/IEDriverServer_x64_2.52.2.exe",
"trustAllSSLCertificates": true
}
I'm guessing Jenkins is trying to connect to a PORT but is unable to do so. Can someone please help?
Make sure the browserName is correct.
"desiredCapabilities": {
"browserName": "internet explorer",
"javascriptEnabled": true,
"acceptSslCerts": true
}
browserName: "internet explorer" and not "ie"
also your are missing the ".exe" in webdriver.chrome.driver

Setting the Firefox profile when using Selenium and Firefox Portable

I'm in a setup, in which I need to use Firefox Portable 38.7.1 for my Selenium tests (version 2.53.0). Everything works fine, but now I need to configure a proxy.
I configured it in the default profile (it gets saved in ${FF_PORTABLE_PATH}/Data/profile/prefs.js)
user_pref("network.proxy.http", "proxyHost");
user_pref("network.proxy.http_port", proxyPort);
user_pref("network.proxy.share_proxy_settings", true);
user_pref("network.proxy.ssl", "proxyHost");
user_pref("network.proxy.ssl_port", 51854);
user_pref("network.proxy.type", 1);
...
When starting the browser manually, this works fine. However, when triggered by Selenium an anonymous profile is created and used, which doesn't have my proxy settings.
I tried to specify the profile when starting the node.
At first I tried using -Dwebdriver.firefox.profile:
java -jar selenium-server-standalone-2.53.0.jar -role node -Dwebdriver.firefox.profile=default
Then I tried to use the default profile as a template using -firefoxProfileTemplate:
java -jar selenium-server-standalone-2.53.0.jar -role node -firefoxProfileTemplate "${FF_PORTABLE_PATH}/Data" -nodeConfig ...
I also created a new profile (using the ProfilistPortable plugin) and specified it on startup of the node (with the webdriver.firefox.profile-parameter).
In all cases the Selenium node opens up Firefox Portable with a "clean" anonymous profile without my proxy settings.
Can anyone help me how to get this setup working with Firefox Portable? I don't really need separate profiles. As long as I can force Selenium to use a profile, which has the proxy configured, I'm fine.
Here's my nodeConfig:
{
"capabilities": [
{
"browserName": "firefox",
"version": "38.7.1",
"firefox_binary": "${FF_PORTABLE_PATH}\\FirefoxPortable.exe",
"platform": "WINDOWS",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5550,
"host": "ip",
"register": true,
"registerCycle": 5000,
"hubHost": "localhost",
"hubPort": 4440
}
}
I use ${FF_PORTABLE_PATH} in the examples above. In reality this (fully qualified) path is hardcoded in all my settings.
I had the same issue. Digging into selenium code I was able to find a solution.
FirefoxBinary binary = new FirefoxBinary(new File(portablePath.trim()));
File profile_dir = new File(portablePath.trim().replace("FirefoxPortable.exe", "/Data/profile"));
fp = new FirefoxProfile(profile_dir);
dc.setCapability(FirefoxDriver.PROFILE, fp);
driver = new FirefoxDriver( binary , fp, dc);