I am trying to run e2e tests for chrome and firefox and I am unable to load the chrome browser with following configuration ,any comment is much appreciated , thanks
var HtmlReporter = require('protractor-beautiful-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [ **some spec**
],
multiCapabilities: [{
"browserName": "firefox"
},
{
"browserName": "chrome",
}
],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 180000
},
allScriptsTimeout: 200000,
onPrepare: function () {
browser.manage().timeouts().implicitlyWait(20000);
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'test-result',
preserveDirectory: false,
takeScreenShotsOnlyForFailedSpecs: true,
screenshotsSubfolder: 'images'
}).getJasmine2Reporter());
}
};
try directConnect: true instead of using seleniumAddress: http://localhost:4444/wd/hub
or make sure your grid server is up and running and also selenium server is up and running
command to start selenium server webdriver-manager start
Related
I'm using Nightwatch, Selenium, and Chrome Driver to conduct automated UI testing. Sometimes there are test failures on any number of remote environments. To debug the failures locally, I would like to keep the browser open on test failure.
I used to be able to do this using config settings in nightwatch.json and nightwatch.conf.js, but I lost my config settings cheat-sheet in a hard drive failure, and despite my best efforts on google I can't seem to find the right combination again.
If I remember correctly, it wasn't any kind of keepBrowserOpen: true type flag. If memory serves, it was some type of timeout set to a silly high number combined with something else like detachDriver. I've checked the Selenium documentation with specific focus on the Chrome Driver Options, and the list of Chrome Driver options, but I haven't found any working combinations.
What am I missing?
Here is my nightwatch.json
{
"output_folder": "tests/automation/reports",
"end_session_on_fail": false,
"test_settings": {
"default": {
"selenium_port": 4444,
"screenshots": {
"enabled": true,
"path": "tests/automation/reports/screenshots"
},
"javascriptEnabled": true,
"acceptSslCerts": true,
"acceptInsecureCerts": true,
"globals": {
"waitForConditionTimeout": 10000
}
},
"chrome": {
"extends": "default",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"acceptInsecureCerts": true,
"chromeOptions": {
"args": [
"--no-sandbox",
"--disable-gpu"
]
}
}
}
}
}
And my nightwatch.conf.js
const geckoDriver = require('geckodriver');
const chromeDriver = require('chromedriver');
const seleniumServer = require('selenium-server');
module.exports = (function (settings) {
settings.selenium = {
start_process: true,
server_path: seleniumServer.path,
log_path: 'tests/automation/reports/',
host: 'localhost',
port: 4444,
cli_args: {
'webdriver.chrome.driver': chromeDriver.path,
'webdriver.gecko.driver': geckoDriver.path,
'webdriver.edge.driver': 'C:\\windows\\system32\\MicrosoftWebDriver.exe',
'webdriver.port': '4444'
}
};
return settings;
})(require('./nightwatch.json'));
Selenium Version is 2.35.1
This is not an elegant solution but close to what you are looking for. Basically, we can check the value of browser.currentTest.results.errors in afterEach() and in case if the value is more than 0, then we can just pause the test there, keeping the browser session alive.
afterEach: function(browser) {
if(browser.currentTest.results.errors > 0) {
browser.pause()
}
I am currently trying to set up webdriver and selenium together to run my automation tests through docker but am facing issues. Each time i try to run the tests I get the following error ERROR wdio-runner: Error: connect ECONNREFUSED 127.0.0.1:4444
I am using the selenium/standalone-chrome from docker and can see that the server is configured correctly and running at 127.0.0.1:4444 as I can hit it.
When I try to run webdriver however I seem to face the issue mentioned above. I believe the issue must be something in my webdriver config but having followed the documentation I can't see what's wrong...
const chai = require('chai');
const chaiWebdriver = require('chai-webdriverio').default;
const debug = process.env.DEBUG;
exports.config = {
runner: 'local',
host: '127.0.0.1',
port: 4444,
path: '/wd/hub',
specs: ['specs/**/*.js'],
suites: {
smoke: ['specs/smoke-spec.js']
},
maxInstances: 10,
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {}
},
sync: true,
logLevel: 'error',
coloredLogs: true,
deprecationWarnings: false,
bail: 0,
debug,
execArgv: debug ? ['--inspect'] : [],
screenshotOnReject: true,
screenshotPath: './error-screenshots',
baseUrl: https://localhost:443,
waitforTimeout: 30000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
seleniumLogs: './selenium-logs',
framework: 'mocha',
reporters: [
[
'allure',
{
outputDir: 'test-output',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false
}
],
['spec', {}]
],
mochaOpts: {
ui: 'bdd',
timeout: 400000,
compilers: ['js:babel-register']
},
before() {
chai.use(chaiWebdriver(browser));
global.expect = chai.expect;
},
afterTest: test => {
if (!test.passed) {
browser.takeScreenshot();
}
}
};
Is anyone else having this problem? It seems that somewhere goog:chromeOptions are not getting passed to chromedriver properly - which results in Chrome just opening with default options.
I'm using the following Capybara/Selenium configuration:
Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions': {
args: %w[ start-maximized ]
}
)
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: capabilities,
driver_opts: {
log_path: "./tmp/chrome#{Time.now.to_i}.log",
verbose: true
}
)
end
Capybara.javascript_driver = :chrome
However, when I open up the Capybara session log, the goog:chromeOptions have not been set at all. Is this why my Chrome window is not maximized?
Session log:
[1550680994.143][INFO]: COMMAND InitSession {
"capabilities": {
"firstMatch": [ {
"browserName": "chrome",
"goog:chromeOptions": {
//nothing is here??? should have args!
}
} ]
},
"desiredCapabilities": {
"browserName": "chrome",
"cssSelectorsEnabled": true,
"goog:chromeOptions": {
//nothing is here??? should have args!
},
"javascriptEnabled": true,
"nativeEvents": false,
"platform": "ANY",
"rotatable": false,
"takesScreenshot": false,
"version": ""
}
}
Operating System:
Ubuntu 18.04
My environment:
ruby 2.6.1
capybara (2.18.0)
selenium-webdriver (3.13.0)
ChromeDriver 2.37.544315
Everytime I run a Selenium test, the window is not maximized. But this isn't another "the screen isn't maximized" post (there are lots of those already). This appears to be an issue where my options are not being parsed properly perhaps? I don't get whats wrong. I'm following all the README's and guides as best I can. Its just not working :(
Fixed it by upgrading Capybara and Selenium Webdriver!
capybara (3.13.2)
selenium-webdriver (3.141.0)
Now the debug log has what I was expecting to see:
[1550686685.534][INFO]: COMMAND InitSession {
"capabilities": {
"firstMatch": [ {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ "start-maximized" ]
}
} ]
},
"desiredCapabilities": {
"browserName": "chrome",
"cssSelectorsEnabled": true,
"goog:chromeOptions": {
"args": [ "start-maximized" ]
},
"javascriptEnabled": true,
"nativeEvents": false,
"platform": "ANY",
"rotatable": false,
"takesScreenshot": false,
"version": ""
}
}
We are trying to execute Protractor tests in CentOS 7 vm in headless mode using chromedriver.
Versions:
Protractor- 5.4.0
Node - v6.14.3
cucumber-js - 4.2.1
Google Chrome version - Google Chrome 68.0.3440.84
Webdriver-manager running and showing following information
[bpmuser#bg-bpm-qa-jbpm6 ~]$ ps -eaf | grep java
root 3692 3685 5 17:19 pts/0 00:00:01 java -
Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.41 -Dwebdriver.gecko.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.21.0 -jar /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.14.0.jar -port 4444
protractor.conf.js:
var Cucumber = require("./node_modules/cucumber");
var { defineSupportCode } = require("./node_modules/cucumber");
var reporter = require('./node_modules/cucumber-html-reporter');
var report = require("./node_modules/cucumber-html-report");
var cucumberReportOptions = {
source: './reports/results.json',
dest: './reports/results',
name: "report_detailed.html",
title: "CDocs Automation Report",
};
var cucumberReporteroptions = {
theme: 'Bootstrap',
jsonFile: './reports/results.json',
output: './reports/results/report.html',
screenshotsDirectory: './reports/screenshots/',
storeScreenshots: true,
reportSuiteAsScenarios: true,
launchReport: false,
metadata: {
"App Version":"Angular 2.0",
"Test Environment": "QA",
"Browser": "Chrome",
"Platform": process.platform,
//"Parallel": "Scenarios",
"Scenarios" : "TestCases",
"Executed": "Local"
}
};
exports.config = {
//directConnect: true,
useAllAngular2AppRoots: true,
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
framework: "custom",
// path relative to the current config file
frameworkPath: require.resolve('./node_modules/protractor-cucumber- framework'),
//restartBrowserBetweenSuites: true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ 'headless' ]
},
acceptSslCerts: true,
},
// Spec patterns are relative to this directory.
specs: ['./features/ChangeView.feature',
],
//baseURL: 'http://localhost:8080/',
onPrepare: function () {
browser.baseUrl = "http://localhost:8080/";
},
onComplete: () => {
reporter.generate(cucumberReporteroptions); //invoke cucumber-html-reporter
report
.create(cucumberReportOptions)
.then(function() {
//invoke cucumber-html-report
// creating two reports(optional) here, cucumber-html-report gives
directory already exists as cucumber-html-reporter already creates the html dir!
// suggestion- use either one of the reports based on your needs
console.log("cucumber_report.html created successfully!");
})
},
cucumberOpts: {
format: ['json:reports/results.json', 'pretty'],
require: ['./features/step_definitions/content_step_definitions.js'],
tags: true,
profile: false,
'no-source': true
}
};
However, running Protractor still does not work:
[bpmuser#bg-bpm-qa-jbpm6 bin]$ pwd
/usr/lib/node_modules/protractor/bin
[bpmuser#bg-bpm-qa-jbpm6 bin]$ ./protractor /home/bpmuser/docs/CDocsAutomation/protractor.conf.js
[18:10:33] I/launcher - Running 1 instances of WebDriver
[18:10:33] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
Its not progressing after this step. Not sure where i am doing wrong.
Try using this in your config
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
}
}
hope this helps
I have this in my Protractor config:
multiCapabilities: [
{
browserName: 'firefox',
firefoxOptions: {
args: ['-headless']
},
'moz:firefoxOptions': {
args: ['-headless']
}
}
]
unfortunately, when I launch Protractor, Firefox still runs in a headful mode. How to the heck do I tell Firefox to as headless?
I know that at the command line, the -headless option should work so.
I guess, you are missing extra hypen (-) in your config.
multiCapabilities: [
{
browserName: 'firefox',
firefoxOptions: {
args: ['--headless']
},
'moz:firefoxOptions': {
args: [ '--headless' ]
}
}
]
Also your browser version should be greater than 56.