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
Related
I just rebuilt our development environment. This forced the latest version of chrome and suddenly the protractor based tests stopped working. After some research, I tracked this down to the fact that our chrome options in the protractor configuration file are now ignored.
Here is the configuration that used to work fine before:
exports.config = {
...
multiCapabilities : [
{
browserName: "chrome",
chromeOptions: {
args: [
"--disable-gpu",
"--headless",
'--no-sandbox',
"--incognito"
]
}
},
},
],
...
};
Before After
protractor 6.0.0 6.0.0
selenium 4.0.0-alpha-1 4.0.0-alpha-1
chrome 74.0.3729.157 76.0.3809.100
chromedriver 74.0.3729.6 76.0.3809.68
In recent versions of selenium you have to specify the chrome options as goog:chromeOptions. So just change the chromeOptions line above to the following:
...
"goog:chromeOptions": {
...
and you are back in business.
"chromeOptions": {}
its still usable in most cases, but does not support new arguments provided by chrome
suggested to use
"goog:chromeOptions": {}
Ref to doc: http://chromedriver.chromium.org/capabilities
Same rule for firefox
"moz:firefoxOptions": {}
Ref to doc: https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions
I am using Protractor for writing e2e test cases in Angular using Jasmin.
I am using Saucelab for executing my test cases on Chrome, Firefox, Edge and IE11.
I came across a issue that hover functionality using mouseMove doesen't work in case of IE11 so i want to skip those test-cases for IE11 but thost test must execute for rest 3 browsers.
My protractor.config.js file as below
...
...
multiCapabilities: ([
{
name: "ds-e2e-firefox",
browserName: "firefox",
version: "63"
},
{
name: "ds-e2e-chrome",
browserName: "googlechrome",
version: "70"
},
{
name: "ds-e2e-edge",
browserName: "MicrosoftEdge",
version: "16",
avoidProxy: true
},
{
name: "ds-e2e-ie11",
browserName: "internet explorer",
version: "11",
iedriverVersion: "3.12.0"
}
]).map(cap => Object.assign(cap, {
platform: "Windows 10",
seleniumVersion: SELENIUM_VERSION,
screenResolution: "1920x1080"
}))
};
...
I am open with some other workaround as i am unable to think how to achieve this.
multicapabilities is collection which takes array of capability so you Can try with exclude keyword reserved for ignoring spec files.
{
name: "ds-e2e-ie11",
browserName: "internet explorer",
version: "11",
iedriverVersion: "3.12.0",
exclude: [specfile.js, specfile2.js]
}
One of the ways to approach it is this way
it("Search by name", async () => {
// open home page
await browser.get(params.baseUrl);
let capabilities = await browser.getCapabilities();
let browserName = capabilities.map_.get('browserName');
if (browserName === "chrome") {
// your test goes here
}
});
When i run tests with https headless, the error below shows up
bash
Error: move target out of bounds: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
Running without --headless option, it works but slower.
Running as http with --headless works too
CodeceptJS version: newest
NodeJS Version:4.2.6
Operating System: Mint
WebDriverIO: newest
Configuration file:
```json
{
"tests": "./**/*_test.js",
"timeout": 10000,
"output": "output",
"helpers": {
"WebDriverIO": {
"smartWait": 50,
"url": "https://172.17.0.1/",
"browser": "chrome",
"restart": false,
"desiredCapabilities": {
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless"]
}
}
}
},
"include": {
"I": "./steps_file.js",
"loginPage": "./pages/Login.js",
"defaultData": "./Data/defaultData.js",
"registerPage": "./pages/Register.js",
"menu": "./pages/Menus.js",
"profilePage": "./pages/Profile.js",
"subscription": "./pages/Subscription.js",
"recordsPage": "./pages/Records.js"
},
"bootstrap": true,
"name": "CodeceptJS",
"plugins": {
"allure": {
"enabled": "true" }
}
}
```
Try using an x instead of a comma (,) when specifying the window size.
Example:
--window-size=1920x1080
Maybe this is related to this:
https://www.chromium.org/for-testers/bug-reporting-guidelines/uncaught-securityerror-failed-to-read-the-localstorage-property-from-window-access-is-denied-for-this-document
You could create Chrome profile where you will turn off this option and load it by providing run parameter (https://chromium.googlesource.com/chromium/src/+/HEAD/docs/user_data_dir.md):
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-data-dir=<YOURDIR>]
}
Another solution you could check if UserAgent string for headless is different than normal browser, and if answer is yes override it with (Chrome 69 UA):
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--user-agent="Mozilla/5.0 AppleWebKit (KHTML, like Gecko) Chrome/69.0 Safari"]
}
And the last one is to turn off security policy by providing parameters:
--disable-web-security
--allow-running-insecure-content
"chromeOptions": {
"args":[
"--window-size=1200,1200",
"--headless",
"--disable-web-security",
"--allow-running-insecure-content"]
}
You can try one of the possible solutions or combine them.
Assume that I've automated 25 tests and executing in multiple browsers like chrome, firefox, IE, Edge & Safari. All tests (25) are executing well on Chrome. In Firefox, Only 20 tests are running fine due to few protractor APIs are not supported. Similarly IE can execute only 23 tests.
I would like to skip the test only for browsers, which are not supported for particular test? Is there any way available?
You can create protracotr.conf file for each browser with specific suites where will be specified what tests should run. And execute in one time all protractor.conf files.
//protractor.chrome.conf
export let config: Config = {
...
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 1
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/chrome/**/*.js'
]
};
and
//protractor.ie.conf
export let config: Config = {
...
capabilities: {
browserName: 'internet explorer',
shardTestFiles: true,
maxInstances: 1
},
SELENIUM_PROMISE_MANAGER: false,
specs: [
'../test/ie/**/*.js'
]
};
in your package.json:
{
...
"scripts": {
"test:all": "npm run test:chrome && test:ie",
"test:chrome": "protractor ./config/protractor.chrome.conf.js",
"test:ie": "protractor ./config/protractor.ie.conf.js",
...
},
...
}
With jasmine2 you can filter tests using a regular expression. Maybe you can add something like #chrome, #ie to your tests and then only run those ones by passing the grep flag:
it('should do stuff #ie #chrome', function() {
...
});
Then run protractor passing the grep flag:
protractor conf.js --grep='#ie'
I have a suite of tests using local drivers built with nightwatch. Works well.
I am running a basic test using Perfecto Mobile and selenium-webdriver. It works with this example.(https://community.perfectomobile.com/series/20208/posts/1002862)
I am trying to connect my suite of nightwatch test to perfecto, but can't start selenium. If this is the url of the selenium server.
var url = "https://mobilecloud.perfectomobile.com/nexperience/perfectomobile/wd/hub";
I tried a few ways to set it up under nightwatch config, but can't make it work.
"selenium" : {
"start_process" : true,
"host" : "mobilecloud.perfectomobile.com/nexperience/perfectomobile/wd/hub"
}
Is there an equivalent to usingServer in nightwatch? I haven't seen anything in the docs.
driver = new webdriver.Builder().
usingServer(url).
withCapabilities(capabilities).
build();
Turns out this was the setup needed.
"test_settings" : {
"perfecto" : {
"use_ssl": true,
"default_path_prefix": "/nexperience/perfectomobile/wd/hub",
"selenium_port" : 443,
"selenium_host" : "mobilecloud.perfectomobile.com",
"desiredCapabilities": {
"browserName": "xxx",
"deviceName": "xxx",
"user": "xxx#xxx.xxx",
"password": "xxx",
"platformName": "xxx"
}
}
}
The important part that didn't work at the time of writing the question: the default_path_prefix was not customizable.
/wd/hub was the default prefix. But I really needed /nexperience/perfectomobile/wd/hub.
Two days later, this commit was introduced. It is available in 0.9.5 release.
https://github.com/nightwatchjs/nightwatch/commit/aa24c2c2334c42388318498f654d8fe2957967d1