Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit bb2c84d

Browse files
authored
Merge pull request #78 from mobify/release-2.1.0
Release 2.1.0
2 parents df3edd7 + 970cd51 commit bb2c84d

File tree

7 files changed

+59
-28
lines changed

7 files changed

+59
-28
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Status: **Ready for Review** or **Open for Visibility**
22
Owner:
3-
Reviewers: @ellenmobify @marlowpayne @mikenikles
3+
Reviewers: @ellenmobify @jasecode
44

55
## Changes
66
- (change1)

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.1.0
2+
- Adds a `triggerClick` command that uses JavaScript's click.
3+
- Renames `navigate` to `clickAndWaitUntilMobified` to avoid colliding with a core Nightwatch command with the same name. Resolves https://github.com/mobify/nightwatch-commands/issues/74
4+
- Warnings related to a missing `site.json` should no longer be output if not using the `.preview()` command. Resolves https://github.com/mobify/nightwatch-commands/issues/73
15
2.0.1
26
-Update [selenium-download](https://github.com/groupon/selenium-download) to 2.0.10
37
- selenium chromedriver 2.29

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ this.demoTest = function (browser) {
165165
};
166166
```
167167

168-
#### navigate(selector, callback)
168+
#### clickAndWaitUntilMobified(selector, callback)
169169

170-
The `navigate` command initiates a `click` command on the supplied selector link, navigates to the URL, and then it initiates the `waitUntilMobified` function before it continues the chain of tests.
170+
The `clickAndWaitUntilMobified` command initiates a `click` command on the supplied selector link, navigates to the URL, and then it initiates the `waitUntilMobified` function before it continues the chain of tests.
171171

172172
Parameter Name | Parameter Type | Description
173173
------------- | -------------- | -----------
@@ -176,7 +176,7 @@ callback | Function | _optional_ A function to call after the curren
176176

177177
```
178178
this.demoTest = function (browser) {
179-
browser.navigate('.myLink');
179+
browser.clickAndWaitUntilMobified('.myLink');
180180
};
181181
```
182182

@@ -267,6 +267,21 @@ this.demoTest = function (browser) {
267267
};
268268
```
269269

270+
#### triggerClick(selector, callback)
271+
272+
The `triggerClick` command uses Javascript's click function on a given selector. Use this when the regular Selenium `.click` does not work.
273+
274+
Parameter Name | Parameter Type | Description
275+
------------- | -------------- | -----------
276+
selector | String | The CSS/Xpath selector to locate the element.
277+
callback | Function | _optional_ A function to call after the current command finishes execution.
278+
279+
```
280+
this.demoTest = function (browser) {
281+
browser.triggerClick('.myLink');
282+
};
283+
```
284+
270285
#### triggerTouch(selector, type, callback)
271286

272287
The `triggerTouch` command simulates a specified touch type event on the supplied DOM element. Use this command when Selenium's `click` does not register.

commands/preview.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,34 @@
2727
*/
2828

2929
var path = require('path');
30+
var qs = require('querystring');
3031

31-
try {
32-
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.json'));
33-
} catch (e) {
34-
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
35-
console.log('Not using optional site.json. Looking for site.js...');
36-
}
37-
}
32+
exports.command = function(url, callback) {
33+
var browser = this;
3834

39-
try {
40-
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.js'));
41-
} catch (e) {
42-
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
43-
console.log('Not using optional /tests/system/site.js.');
35+
try {
36+
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.json'));
37+
} catch (e) {
38+
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
39+
console.log('Not using optional site.json. Looking for site.js...');
40+
}
4441
}
45-
}
4642

47-
try {
48-
var siteConfig = require(path.join(path.resolve('./'), '/system/site.js'));
49-
} catch (e) {
50-
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
51-
console.log('Not using optional /system/site.js.');
43+
try {
44+
var siteConfig = require(path.join(path.resolve('./'), '/tests/system/site.js'));
45+
} catch (e) {
46+
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
47+
console.log('Not using optional /tests/system/site.js.');
48+
}
5249
}
53-
}
5450

55-
var qs = require('querystring');
56-
57-
exports.command = function(url, callback) {
58-
var browser = this;
51+
try {
52+
var siteConfig = require(path.join(path.resolve('./'), '/system/site.js'));
53+
} catch (e) {
54+
if (e instanceof Error && e.code === 'MODULE_NOT_FOUND') {
55+
console.log('Not using optional /system/site.js.');
56+
}
57+
}
5958

6059
if (siteConfig) {
6160
var site = siteConfig.profiles[siteConfig.activeProfile];

commands/triggerClick.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
exports.command = function(selector, callback) {
2+
var client = this;
3+
/*
4+
/ Use Javascript's click when Selenium's does not register.
5+
*/
6+
client.execute('document.querySelector("' + selector + '").click();', function(result) {
7+
if (typeof callback === 'function') {
8+
callback.call(client, result);
9+
}
10+
});
11+
12+
return this;
13+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nightwatch-commands",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "A set of Mobify specific custom commands for Nightwatch.js",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)