Run WebDriver with Chrome Canary? - selenium-chromedriver

Is there a way to tell chromedriver (the webdriver implementation within Chrome) to use Canary, Beta or current production chrome?

You can ask ChromeDriver to use a Chrome executable in a non-standard location
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome.exe");
On Mac OS X, this should be the actual binary, not just the app. e.g., /Applications/Google Chrome.app/Contents/MacOS/Google Chrome.
[via chromedriver Capabilities and Switches]

And the way to do this in theintern is by the following config
capabilities: {
'selenium-version': '2.35.0',
'chrome': {chromeOptions: {'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'}},
},
Also, if you're looking to configure the selenium node directly here's how to pass the configuration in:
{
"capabilities": [
{
"browserName": "chrome",
"platform": "MAC"
},
{
"browserName": "chromeCanary",
"platform": "MAC",
"chromeOptions": {
"binary": "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
},
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "firefox",
"platform": "MAC"
}
],
"configuration": {
"host": "localhost",
"port": 8989,
"hubPort": 4444,
"hubHost": "localhost"
}
}

It should be this Google Chrome Canary.app and not just Google Chrome.app.
Try this:
options.setBinary("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary");
ChromeDriver driver = new ChromeDriver(options);

Related

What is the proper capabilities to setup android chrome browser in Appium 1.15.1?

I'm trying to launch chrome browser on emulator but not able to do so. I tried with below capabilities but its going in hung state.
{
"deviceName": "Pixel 2 API 28",
"udid": "emulator-5554",
"platformName": "Android",
"platformVersion": "9.0",
"automationName": "UiAutomator1",
"androidPackage": "com.android.chrome",
"browserName": "Chrome",
"unicodeKeyboard": true,
"resetKeyboard": true
}

Nightwatch with Chrome on Windows: Currently Unusable?

Since my chrome update, I cannot make any nightwatch tests work on Windows 10.
At first the system simply couldn't set values. So I updated to the latest nightwatch, then updated to latest chromedriver.exe and latest selenium jar.
Now the test simply shows data: in the url of the driven browser instead of loading the page. There is also a "disable developer mode extensions" popup and a warning that "--ignore-certificate-errors" is no longer supported.
Any ideas what I'm supposed to have done?
Chromedriver.exe version: 2.38
Selenium Standalone Server: selenium-server-standalone-3.9.1.jar
Nightwatch version: nightwatch#0.9.21
Thanks for any help. Here's my config:
{
"src_folders": ["tests"],
"output_folder": "reports",
"custom_commands_path": "",
"custom_assertions_path": "",
"page_objects_path": "pages",
"globals_path": "globals",
"selenium": {
"start_process": true,
"server_path": "./lib/selenium-server-standalone-3.9.1.jar",
"log_path": "./reports",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "./lib/chromedriver.exe"
}
},
"test_settings": {
"default": {
"launch_url": "https://modaquote.com",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
You have to update Chromedriver to match your new version of Chrome. It should fix there issues.

Protractor tests not working in chrome headless mode

element(by.id('username')).sendKeys('deepu');
this throws the following error in headless mode,
Failed: No element found using locator: By(css selector, *[id="username"])
this is running fine in normal mode.
My package.json
"dependencies": {
"jasmine": "2.4.1",
"typescript": "^2.1.6"
},
"devDependencies": {
"#types/jasmine": "2.5.51",
"#types/jasminewd2": "^2.0.0",
"chromedriver": "^2.34.1",
"protractor": "^5.2.2",
"protractor-jasmine2-html-reporter": "0.0.7",
"selenium-server-standalone-jar": "^3.8.1",
"ts-node": "^3.0.2"
}
Chrome version
63.0.3239.132 (Official Build) (64-bit)
Thanks in advance,
Deepu.
UPDATE
The actual problem was in ignoring certificate errors in the headless Chrome.
I was able to run the tests fine, bypassing the untrusted certificate warning from browser, with Protractor and Firefox Quantum(57.0.4, 64-bit) headless, but had to run a standalone selenium, couldn't find anything similar to chromedriver
framework: 'jasmine',
capabilities: {
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [ "--headless" ]
}
},
specs: [ './specs/login.spec.js' ],
seleniumAddress: 'http://localhost:4444/wd/hub',

Passing chromeOptions args to the selenium node in .json file on Linux

I'm trying to create node with following configurations:
java -Dwebdriver.chrome.driver=/randomfolder/chromedriver -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig node-conf.json
As you see I'm passing config in a json file. It sets the configurations correctly, except the chromeOptions. I need chrome to be opened headless. This is a part of my .json file, which sets the capabilities.
"capabilities": [
{
"browserName":"chrome",
"maxInstances":3,
"version":"ServerLinux",
"platform":"LINUX",
"chromeOptions": {
"args": ["--headless", "--disable-gpu" , "--window-size=1920x1080", "--no-sandbox"]
}
}
]
I've tried different ways of writing the chromeOptions, but node keeps constantly ignoring them. Am I just blind and don't see my mistake?
Thanks in advance!
I am also facing this issue, but in my case, I want to modify the user agent, and on Linux, chromeOptions just seems to be ignored. This is working for me locally on Mac/Chrome.
//wdio.conf.js
capabilities: [{
browserName: "chrome",
chromeOptions : {
args : ['--user-agent=THIS_IS_A_TEST']
}
}],
//Jenkins job on Linux RHEA
13:42:33 [11/10/2018 13:42:33.049] [LOG] browser.desiredCapabilities = {
13:42:33 "javascriptEnabled": true,
13:42:33 "locationContextEnabled": true,
13:42:33 "handlesAlerts": true,
13:42:33 "rotatable": true,
13:42:33 "browserName": "chrome",
13:42:33 "acceptInsecureCerts": true,
13:42:33 "chromeOptions": {
13:42:33 "args": [
13:42:33 "--user-agent=THIS_IS_A_TEST",
13:42:33 "window-size=1600,1200"
13:42:33 ]
13:42:33 },
13:42:33 "loggingPrefs": {
13:42:33 "browser": "ALL",
13:42:33 "driver": "ALL"
13:42:33 }
13:42:33 }
13:42:33 [11/10/2018 13:42:33.072] [LOG] printNavigatorUserAgent() navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Expected: printNavigatorUserAgent() navigator.userAgent = THIS_IS_A_TEST
printNavigatorUserAgent(){
let result = browser.execute(function() {
return navigator.userAgent;
},);
console.log(`printNavigatorUserAgent() navigator.userAgent = ${result.value}`);
}
Update: The following syntax is currently working for me on Linux/chrome.
//wdio.conf.js
capabilities: [{
browserName: "chrome",
"goog:chromeOptions" : {
"args" : ['user-agent=THIS_IS_A_TEST']
}
}],
A "try and guess" for the right JSON syntax is time consuming, and the schema might change anyway. The safest option is to pick the API for your language of choice, then assemble and generate the JSON yourself. Make sure to pick the version matching the Selenium site and stack you are targeting.
Example with Python:
from selenium.webdriver.chrome.options import Options as ChromeOptions
options = ChromeOptions()
options.add_argument('--incognito')
options.to_capabilities()
and that will look like:
{
'browserName': 'chrome',
'version': '',
'platform': 'ANY',
'goog:chromeOptions': {
'extensions': [],
'args': ['--incognito']
}
}
As a final note, if your site is bringing in a capabilities list of its own, this override and that one might get merged, so bring in your deltas only to avoid surprises.

What is the difference between Selenium and WebDriver seleniumProtocol in DefaultNode.json?

I am trying to set up Selenium Grid 2 and grabbed a sample json config file from here. My tests are written in C# using Selenium WebDriver. I am trying to figure out the difference between these two protocols and which one I should be using for WebDriver test.
There is another file here only for WebDriver . My understanding is "seleniumProtocol": "Selenium" provides the mechanism for Selenium 1 and "seleniumProtocol": "WebDriver" for Selenium WebDriver.
{
"capabilities":
[
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
},
{
"platform": "WINDOWS",
"browserName": "internet explorer",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration":
{
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"host": ip,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": ip
}
}
Depending on the protocols commandline arguments changes too. I have another post here related to commandline to start the nodes