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": ""
}
}
Related
Using below configuration as capabilities for the remote firefox browser(saucelabs)-
12:34:32.312 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "firefox",
"moz:firefoxOptions": {
"profile": "Test1",
"prefs": {
"devtools.chrome.enabled": false,
"media.webrtc.hw.h264.enabled": true,
"media.peerconnection.ice.tcp": true,
"dom.webnotifications.enabled": false,
"media.gmp-manager.updateEnabled": true,
"devtools.console.stdout.content": true,
"media.getusermedia.screensharing.enabled": true,
"devtools.debugger.remote-enabled": true,
"media.peerconnection.video.h264_enabled": true,
"marionette": true,
"media.navigator.permission.disabled": true,
"devtools.debugger.prompt-connection": false,
"media.navigator.streams.fake": true
},
"log": {
"level": "trace"
},
"args": [
"--use-fake-device-for-media-stream",
"--use-fake-ui-for-media-stream",
"--start-maximized",
"--disable-web-security",
"enable-logging",
"-start-debugger-server",
"9222"
]
},
"selenium:webdriver.remote.quietExceptions": false
}
Yet unable to get the console info into the selenium-driver.log in saucelabs. Even setting the option "devtools.console.stdout.content": true also not yielding any file with geckodriver.log.
With the same settings, chrome console logs are being captured as part of selenium-driver.log. Is there anything to be configured for getting console output for remote firefox?
Any input on this is very much appreciated.
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 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
I run into the following problem after updating webdriver-manager:
E/launcher - SessionNotCreatedError: Unable to create session from
my config is printed here
webdriver-manager Version: 12.1.5
Node Version: 10.15.3
Protractor Version: 5.4.2
Browser(s): Chrome
Operating System and Version: Win 7 / Ubuntu
This is my config file which worked for the last 1.5 years:
exports.config = {
"seleniumAddress": "http://localhost:4444/wd/hub",
"seleniumPort": "4444",
"capabilities": {
"browserName": "chrome",
"unexpectedAlertBehaviour": "accept",
"perform": "ANY",
"version": "ANY",
"chromeOptions": {
"perfLoggingPrefs": {
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
},
"prefs": {
"credentials_enable_service": false
},
"args": ["--headless", "--window-size=800,1080", "--disable-blink-features=BlockCredentialedSubresources", "--no-sandbox", "--test-type=browser", "--disable-dev-shm-usage", "--enable-gpu-benchmarking", "--enable-thread-composting" , "--start-maximized"]
},
"loggingPrefs": { "performance": "ALL" }
},
"jasmineNodeOpts": {
"showColors": true,
"defaultTimeoutInterval": 9999999
},
"allScriptsTimeout": 200000,
"params": {
"perf": {
"selenium": { "protocol": "http:", "slashes": true, "auth": null, "host": "localhost:4444", "port": 4444, "hostname": "localhost", "hash": null, "search": null, "query": null, "pathname": "/wd/hub", "path": "/wd/hub", "href": "http://localhost:4444/wd/hub" },
"browsers": [{
"browserName": "chrome",
"chromeOptions": {
"perfLoggingPrefs": {
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
},
"args": ["--headless", "--disable-gpu", "--disable-blink-features=BlockCredentialedSubresources", "--no-sandbox", "--test-type=browser", "--disable-dev-shm-usage"]
},
"loggingPrefs": { "performance": "ALL" }
}],
"debugBrowser": false,
"actions": ["scroll"],
"metrics": ["TimelineMetrics", "ChromeTracingMetrics", "RafRenderingStats", "NetworkTimings", "NetworkResources"],
"metricOptions": {}
},
"warmup": false,
"agilar" : false
}
}
I know the file is a mess and it's more or less googled together, but it worked. Can you point me to what is causing this problem?
Is selenium server up and running at default address
"http://localhost:4444/wd/hub" . If it's not , start it by running : webdriver-manager start. Assuming you have webdriver-manager installed already.
Also I dont think you need to define seleniumPort when you have selenium address property given already in config. So remove this property "seleniumPort": "4444" from config.
for some reason, I have not been able to get tests working in Microsoft Edge Windows 10.
Here's my nightwatch config
"edge": {
"use_ssl": false,
"silent": true,
"output": true,
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"platform": "Windows 10",
"version": "13.10586",
"screenResolution": "1280x1024",
"avoidProxy": true
}
}
Has anyone been able to get their tests working in Microsoft Edge?
If so, what version of selenium do you use? I use 2.52
What version of the edge driver do you use?
First of all you need Microsoft Edge Webdriver. You may download it from here: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Then in nigthwatch.js config you need to specify path to you edge webdriver (webdriver.edge.driver arg). This is how my config looks like:
"selenium": {
"start_process": true,
"server_path": "./node_modules/file_dependencies/selenium-server-standalone.jar",
"log_path": "",
"host": "127.0.0.1",
"port": seleniumPort,
"cli_args": {
"webdriver.chrome.driver": "./node_modules/file_dependencies/chromedriver.exe",
"webdriver.ie.driver": "./node_modules/file_dependencies/IEDriverServer.exe",
"webdriver.edge.driver": "C:/Program Files (x86)/Microsoft Web Driver/MicrosoftWebDriver.exe",
"webdriver.gecko.driver": "./node_modules/file_dependencies/geckodriver.exe",
"webdriver.firefox.profile": ""
}
}
Rest of your config looks fine
I had issues getting edge to work using Selenium 3.9.1 where Selenium was attempting to use the geckodriver to run tests against Edge.
My configuration looked as follows (snippet to keep to the point):
"selenium" : {
"cli_args" : {
"webdriver.chrome.driver" : "bin\\chromedriver.exe",
"webdriver.edge.driver" : "bin\\MicrosoftWebDriver.exe",
"webdriver.gecko.driver" : "bin\\geckodriver.exe",
"webdriver.firefox.profile": ""
}
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName": "edge",
"marionette": true
}
}
}
I was able to get around this by changing "edge" to "ie" and the browser name to "internet explorer" - see the updated configuration:
"selenium" : {
"cli_args" : {
"webdriver.chrome.driver" : "bin\\chromedriver.exe",
"webdriver.ie.driver" : "bin\\MicrosoftWebDriver.exe",
"webdriver.gecko.driver" : "bin\\geckodriver.exe",
"webdriver.firefox.profile": ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "internet explorer",
"marionette": true
}
}
}
The auto-generated nightwatch.conf.js already includes configuration for Edge browser, so you can just run by flagging the edge environment:
nightwatch --env edge