mobify / nightwatch-commands Goto Github PK
View Code? Open in Web Editor NEWA set of Mobify specific custom commands for Nightwatch.js
A set of Mobify specific custom commands for Nightwatch.js
For example, to use footer or header in one place and use it globally
On process error the selenium session is not killed,
Expected:
Call to kill selenium session needs to be added to ensure the session is terminated correctly on process error
When installing nightwatch-commands, a copy of selenium-server.jar and a chromedriver binary are downloaded as well. If these files already exist, perhaps we don't need to redownload every time.
To save time and bandwidth, don't download selenium-server and chromedriver binary if they already exist locally.
Download every time.
package.json
, use a different version of nightwatch-commandsnpm install
Expand on the waitForUrl command to allow for a URL to contain a specified value.
The waitForUrl command is limited to an exact match, we want a command to wait for url to contain a certain string, this is useful in cases where the URL might append a session hash or randomly generated token. ex 'http://www.mystore.com/checkout?123456789" we would want to wait for "http://www.mystore.com/checkout"
I get the following error
Error: The command "navigate" is already defined!
when adding
"custom_commands_path": "./node_modules/nightwatch-commands/commands",
to my config.
Is suspect it collides with the core navigate
command introduced here.
Nightwatch doesn't throw an error when adding commands to custom_commands_path
Throws an error
Error: The command "navigate" is already defined!
npm install nightwatch-commands --save-dev
Add to nightwatch.json
"custom_commands_path": "./node_modules/nightwatch-commands/commands",
Run nightwatch
nightwatch-commands support for nightwatch v1
I tried integrating the nightwatch-commands package with nightwatch (version 1.2.1) and I am getting the below issue.
@ellenmobify - It will be greatly appreciated if you can look at this issue.
λ npm run chrome
> [email protected] chrome C:\Users\sthoma40\MyDocs\Officeworks\Automation\nightwatchjs-selenium-example
> nightwatch -e chrome
[Github] Test Suite
===================
Running: Demo test GitHub
TypeError: Error while running "waitForCondition" command: "TypeError: Class constructor ProtocolActions cannot be invoked without 'new'
"
FAILED: 1 errors (1.355s)
TypeError: Error while running "waitForCondition" command: "TypeError: Class constructor ProtocolActions cannot be invoked without 'new'
"
module.exports = {
tags: ['git'],
'Demo test GitHub': function (client) {
client
.url('https://github.com/nightwatchjs/nightwatch')
.waitForAjaxCompleted()
.waitForElementVisible('body', 1000)
.getTitle(function (result) {
client.assert.equal(result.indexOf('GitHub - nightwatchjs/nightwatch'), 0, 'Page title starts with nightwatch')
})
.assert.visible('.container h1 strong a')
.assert.containsText('.container h1 strong a', 'nightwatch', 'Checking project title is set to nightwatch');
},
after: function (client) {
client.end();
}
};
module.exports = {
src_folders: ['tests'],
output_folder: 'output/reports',
custom_commands_path: './node_modules/nightwatch-commands/commands',
custom_assertions_path: '',
page_objects_path: '',
"devDependencies": {
"chromedriver": "^75.1.0",
"edgedriver": "^4.17134.1",
"geckodriver": "^1.16.2",
"iedriver": "^3.14.1",
"nightwatch": "^1.2.1",
"nightwatch-commands": "^3.0.0",
"selenium-server": "^3.141.59"
}
For example, in a condition like this I want to pass the selector
argument:
const condition = (selector) => {
return !! $(selector).attr('disabled')
}
But it looks like there is no way to do this except of constructing condition as string:
// like this
const condition = `return !! $(${selector}).attr('disabled')`
// or this
const conditionFunc = () => {
return !! $({{SELECTOR}}).attr('disabled')
}
const condition = conditionFunc.toString().replace('{{SELECTOR}}', selector)
Not a big deal in the exampe, but there might be really big condition functions where such constructing can really bother.
Wouldn't it be as simple to add support for arguments as to add the extra argument for the execute
call here?
nightwatch-commands/commands/waitForCondition.js
Lines 49 to 69 in 4d3984a
We need to be able to specify multiple site profiles in the site.json file.
Example:
{
activeProfile: "en";
profiles: [
"en" : {
"bundleUrl": ""
},
"fr": {
"bundleUrl": ""
}
];
}
We need the ability to set a flag to production, so that browser.preview() will just get whatever URL is set in the site.json file.
example:
site.json:
{
"bundleUrl": "bundle location",
"siteUrl": "http://www.customer.com"
"production": "true"
}
header.js
module.exports = {
'setUp': function(browser) {
//because production set to true, preview defaults to .get("http://www.customer.com")
browser.preview();
},
Our conf currently:
// see http://selenium-release.storage.googleapis.com/index.html for latest
var seleniumVersion = '2.40.0';
// see http://chromedriver.storage.googleapis.com/index.html
var chromeDriverVersion = '2.9';
Latest versions are 2.45.0 and 2.15, respectively.
Updating will require the following fixes:
browser.getAttribute('<selector>', 'value', function(result) {
...
});
We could really use if/else logic functions for presence/visibility of page elements. This would allow us to set up tests with conditional checks and adjust the test accordingly. For example, to check whether a "Sold out"-type element is present, and divert an Add-to-cart flow to add a different, non-sold-out item.
Possible commands could be:
ifElementExists(selector)
ifElementNotExists(selector)
ifElementVisible(selector)
ifElementHidden(selector)
A possible test flow using a command could be of the form:
ifElementExists(selector) {
do foo
} else {
do bar
}
We really need a swipe command to test gestures on page elements (swipe through carousels, etc).
Potential arguments could include:
I try to use waitUntilMobified()
to wait for my new page to be loaded, but when I use it in my test I get the following error:
Error while running waitForCondition command: Cannot find module 'nightwatch/lib/api/protocol.js'
currently I am unable to determine if the value of an attribute contains "/images/myImage.png" as image paths change for environments I would like to use contains rather than equals.
example would be:
.verify.attributeContains(selectors.headerLogo + ' img', 'src', '/images/myImage.png')
Hello,
When I execute npm test
I get the following error on some tests:
Error: Cannot find module '/home/andregoulart/projetos/nightwatch-commands/tests/tests/system/site.json'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/andregoulart/projetos/nightwatch-commands/commands/preview.js:29:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Does anyone else get this problem? It seems there's no .../tests/system/site.json
file.
Thanks in advance!
I'm using thie package solely for waitForAjaxCompleted
and it outputs a warning or something that I'm not using site.js
.
Package should not output anything that's unrelated to actual commands the developer is using
Package warns about something
Install and enable the package, then run a test
Issue when running nightwatch tests using latest master code from nightwatch-commands
Error in terminal reads:
TypeError: Cannot read property 'undefined' of undefined
at Object. (/Users/Marlow/Development/Mobifyjs-coasthotels-mobile/node_modules/nightwatch-commands/commands/preview.js:32:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /Users/Marlow/Development/Mobifyjs-coasthotels-mobile/node_modules/nightwatch/lib/core/api.js:247:29
at Array.forEach (native)
at loadCustomCommands (/Users/Marlow/Development/Mobifyjs-coasthotels-mobile/node_modules/nightwatch/lib/core/api.js:245:18)
I have performed a workaround by rolling back my local master to before the last PR was merged, and created a new "rollback" branch with which to rollback my nightwatch-commands in my nightwatch tests (inside of package.json: "nightwatch-commands": "git+https://github.com/mobify/nightwatch-commands.git#rollback").
The signature for waitForCondition is inconsistent between params timeout
& milliSeconds
so idk which is which
We need a command to detect once an element has transitioned to another state, specifically whether or not a class has been added to show/hide an element (for example).
Pretty please @kbingman
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.