-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infrastructure: Add util queryElement function to regression test uti…
…ls (pull #1486) Fixes #1403 by adding a `queryElement` helper in /test/util. This commit also replaces all the calls to `queryElements` with `queryElement` when only the first element is needed.
- Loading branch information
1 parent
6f4d05b
commit e8a984c
Showing
7 changed files
with
58 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const { By } = require('selenium-webdriver'); | ||
|
||
/** | ||
* Return the first element found by selector. Wraps Selenium's findElement, but with a failing text for empty queries | ||
* | ||
* @param {ExecutionContext} t - Test execution context | ||
* @param {String} selector - CSS selector string | ||
* @param {Element} context - Element to query within, defaulting to t.context.session | ||
* | ||
* @returns {Promise} Resolves to an element | ||
*/ | ||
module.exports = async function queryElement(t, selector, context) { | ||
context = context || t.context.session; | ||
const result = await context.findElement(By.css(selector)); | ||
if (!result) { | ||
t.fail(`Element query returned no result: ${selector}`); | ||
} | ||
return result; | ||
} |