Mercurial > gemma
annotate client/tests/e2e/custom-assertions/elementCount.js @ 625:4acf60d1bbb4
clients: shorten ECDIS layer name.
* Removing `(D4D)` to shorten layer name for a better layout.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Tue, 11 Sep 2018 17:03:22 +0200 |
parents | 7c40e9f28f94 |
children | 0c5cbbafbd94 |
rev | line source |
---|---|
164
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 // A custom Nightwatch assertion. |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
2 // The assertion name is the filename. |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
3 // Example usage: |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
4 // |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
5 // browser.assert.elementCount(selector, count) |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
6 // |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
7 // For more information on custom assertions see: |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
8 // http://nightwatchjs.org/guide#writing-custom-assertions |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
10 exports.assertion = function elementCount(selector, count) { |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
11 this.message = `Testing if element <${selector}> has count: ${count}`; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
12 this.expected = count; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
13 this.pass = val => val === count; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
14 this.value = res => res.value; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
15 function evaluator(_selector) { |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
16 return document.querySelectorAll(_selector).length; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 } |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
18 this.command = cb => this.api.execute(evaluator, [selector], cb); |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 }; |