Mercurial > gemma
annotate client/tests/e2e/custom-assertions/elementCount.js @ 3450:213b703bdd85
afdLNWL: CSV-Export
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 24 May 2019 12:51:12 +0200 |
parents | 0c5cbbafbd94 |
children |
rev | line source |
---|---|
1364
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
2 * without warranty, see README.md and license for details. |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
3 * |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
6 * |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
9 * Software engineering by Intevation GmbH |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
10 * |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
11 * Author(s): |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
13 */ |
0c5cbbafbd94
add headers license for some client files
Fadi Abbud <fadi.abbud@intevation.de>
parents:
164
diff
changeset
|
14 |
164
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
15 // A custom Nightwatch assertion. |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
16 // The assertion name is the filename. |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 // Example usage: |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
18 // |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 // browser.assert.elementCount(selector, count) |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 // |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
21 // For more information on custom assertions see: |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
22 // http://nightwatchjs.org/guide#writing-custom-assertions |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
23 |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
24 exports.assertion = function elementCount(selector, count) { |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
25 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
|
26 this.expected = count; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 this.pass = val => val === count; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 this.value = res => res.value; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
29 function evaluator(_selector) { |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
30 return document.querySelectorAll(_selector).length; |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 } |
7c40e9f28f94
test: Moved testfile. Established nightwatch tests
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 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
|
33 }; |