diff --git a/.node-version b/.node-version index 2f5ee74..cb3d7a3 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -14.15.1 +16.4.2 diff --git a/package.json b/package.json index c14e41b..045ceb4 100644 --- a/package.json +++ b/package.json @@ -14,29 +14,28 @@ "getUrl": "https://github.com/qustodio/itui/issues" }, "dependencies": { - "@babel/cli": "^7.12.16", - "@babel/core": "^7.12.16", - "@babel/plugin-proposal-export-default-from": "^7.12.13", + "@babel/cli": "^7.17.6", + "@babel/core": "^7.17.8", + "@babel/plugin-proposal-export-default-from": "^7.16.7", "@babel/preset-env": "^7.12.16", - "@babel/register": "^7.12.13", + "@babel/register": "^7.17.7", "@cucumber/cucumber": "^7.3.2", - "@wdio/cli": "^7.0.5", - "@wdio/config": "^7.0.4", - "@wdio/cucumber-framework": "^7.16.14", - "@wdio/local-runner": "^7.16.16", - "@wdio/sauce-service": "^7.0.5", - "@wdio/selenium-standalone-service": "^7.0.4", - "@wdio/spec-reporter": "^7.0.4", - "@wdio/static-server-service": "^7.0.4", - "@wdio/sync": "^7.0.5", - "chromedriver": "^88.0.0", + "@wdio/cli": "^7.19.0", + "@wdio/config": "^7.19.0", + "@wdio/cucumber-framework": "^7.19.0", + "@wdio/local-runner": "^7.19.0", + "@wdio/sauce-service": "^7.19.0", + "@wdio/selenium-standalone-service": "^7.19.0", + "@wdio/spec-reporter": "^7.19.0", + "@wdio/static-server-service": "^7.19.0", + "chromedriver": "^99.0.0", "eslint": "^7.20.0", "eslint-config-airbnb-base": "^14.2.1", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-wdio": "^7.0.0", - "http-server": "^0.12.3", + "eslint-plugin-import": "^2.25.4", + "eslint-plugin-wdio": "^7.19.0", + "http-server": "^14.1.0", "npm-run-all": "^4.1.5", - "wdio-chromedriver-service": "^6.0.4", - "webdriverio": "^7.16.16" + "wdio-chromedriver-service": "^7.3.2", + "webdriverio": "^7.19.0" } } diff --git a/src/steps/given.js b/src/steps/given.js deleted file mode 100644 index fe48c79..0000000 --- a/src/steps/given.js +++ /dev/null @@ -1,133 +0,0 @@ -import { Given } from '@cucumber/cucumber'; - -import checkContainsAnyText from '../support/check/checkContainsAnyText'; -import checkIsEmpty from '../support/check/checkIsEmpty'; -import checkContainsText from '../support/check/checkContainsText'; -import checkCookieContent from '../support/check/checkCookieContent'; -import checkCookieExists from '../support/check/checkCookieExists'; -import checkDimension from '../support/check/checkDimension'; -import checkElementExists from '../support/check/checkElementExists'; -import checkEqualsText from '../support/check/checkEqualsText'; -import checkModal from '../support/check/checkModal'; -import checkOffset from '../support/check/checkOffset'; -import checkProperty from '../support/check/checkProperty'; -import checkPropertyContains from '../support/check/checkPropertyContains'; -import checkSelected from '../support/check/checkSelected'; -import checkTitle from '../support/check/checkTitle'; -import checkUrl from '../support/check/checkURL'; -import closeAllButFirstTab from '../support/action/closeAllButFirstTab'; -import compareText from '../support/check/compareText'; -import isEnabled from '../support/check/isEnabled'; -import isDisplayed from '../support/check/isDisplayed'; -import openWebsite from '../support/action/openWebsite'; -import setWindowSize from '../support/action/setWindowSize'; - -Given( - /^I open the (url|site) "([^"]*)?"$/, - openWebsite -); - -Given( - /^the element "([^"]*)?" is( not)* displayed$/, - isDisplayed -); - -Given( - /^the element "([^"]*)?" is( not)* enabled$/, - isEnabled -); - -Given( - /^the element "([^"]*)?" is( not)* selected$/, - checkSelected -); - -Given( - /^the checkbox "([^"]*)?" is( not)* checked$/, - checkSelected -); - -Given( - /^there is (an|no) element "([^"]*)?" on the page$/, - checkElementExists -); - -Given( - /^the title is( not)* "([^"]*)?"$/, - checkTitle -); - -Given( - /^the element "([^"]*)?" contains( not)* the same text as element "([^"]*)?"$/, - compareText -); - -Given( - /^the (button|element) "([^"]*)?"( not)* matches the text "([^"]*)?"$/, - checkEqualsText -); - -Given( - /^the (button|element|container) "([^"]*)?"( not)* contains the text "([^"]*)?"$/, - checkContainsText -); - -Given( - /^the (button|element) "([^"]*)?"( not)* contains any text$/, - checkContainsAnyText -); - -Given( - /^the (button|element) "([^"]*)?" is( not)* empty$/, - checkIsEmpty -); - -Given( - /^the page url is( not)* "([^"]*)?"$/, - checkUrl -); - -Given( - /^the( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"$/, - checkProperty -); - -Given( - /^the( css)* attribute "([^"]*)?" from element "([^"]*)?" does( not)* contain "([^"]*)?"$/, - checkPropertyContains -); - -Given( - /^the cookie "([^"]*)?" contains( not)* the value "([^"]*)?"$/, - checkCookieContent -); - -Given( - /^the cookie "([^"]*)?" does( not)* exist$/, - checkCookieExists -); - -Given( - /^the element "([^"]*)?" is( not)* ([\d]+)px (broad|tall)$/, - checkDimension -); - -Given( - /^the element "([^"]*)?" is( not)* positioned at ([\d]+)px on the (x|y) axis$/, - checkOffset -); - -Given( - /^I have a screen that is ([\d]+) by ([\d]+) pixels$/, - setWindowSize -); - -Given( - /^I have closed all but the first (window|tab)$/, - closeAllButFirstTab -); - -Given( - /^a (alertbox|confirmbox|prompt) is( not)* opened$/, - checkModal -); diff --git a/src/steps/then.js b/src/steps/then.js deleted file mode 100644 index 05f4e8a..0000000 --- a/src/steps/then.js +++ /dev/null @@ -1,199 +0,0 @@ -import { Then } from '@cucumber/cucumber'; - -import checkClass from '../support/check/checkClass'; -import checkContainsAnyText from '../support/check/checkContainsAnyText'; -import checkIsEmpty from '../support/check/checkIsEmpty'; -import checkContainsText from '../support/check/checkContainsText'; -import checkCookieContent from '../support/check/checkCookieContent'; -import checkCookieExists from '../support/check/checkCookieExists'; -import checkDimension from '../support/check/checkDimension'; -import checkEqualsText from '../support/check/checkEqualsText'; -import checkFocus from '../support/check/checkFocus'; -import checkInURLPath from '../support/check/checkInURLPath'; -import checkIsOpenedInNewWindow from - '../support/check/checkIsOpenedInNewWindow'; -import checkModal from '../support/check/checkModal'; -import checkModalText from '../support/check/checkModalText'; -import checkNewWindow from '../support/check/checkNewWindow'; -import checkOffset from '../support/check/checkOffset'; -import checkProperty from '../support/check/checkProperty'; -import checkPropertyContains from '../support/check/checkPropertyContains'; -import checkFontProperty from '../support/check/checkFontProperty'; -import checkSelected from '../support/check/checkSelected'; -import checkTitle from '../support/check/checkTitle'; -import checkTitleContains from '../support/check/checkTitleContains'; -import checkURL from '../support/check/checkURL'; -import checkURLPath from '../support/check/checkURLPath'; -import checkWithinViewport from '../support/check/checkWithinViewport'; -import compareText from '../support/check/compareText'; -import isEnabled from '../support/check/isEnabled'; -import isExisting from '../support/check/isExisting'; -import isVisible from '../support/check/isDisplayed'; -import waitFor from '../support/action/waitFor'; -import waitForVisible from '../support/action/waitForDisplayed'; -import checkIfElementExists from '../support/lib/checkIfElementExists'; - -Then( - /^I expect that the title is( not)* "([^"]*)?"$/, - checkTitle -); - -Then( - /^I expect that the title( not)* contains "([^"]*)?"$/, - checkTitleContains -); - -Then( - /^I expect that element "([^"]*)?" does( not)* appear exactly (-?\d+) times$/, - checkIfElementExists -); - -Then( - /^I expect that element "([^"]*)?" is( not)* displayed$/, - isVisible -); - -Then( - /^I expect that element "([^"]*)?" becomes( not)* displayed$/, - waitForVisible -); - -Then( - /^I expect that element "([^"]*)?" is( not)* within the viewport$/, - checkWithinViewport -); - -Then( - /^I expect that element "([^"]*)?" does( not)* exist$/, - isExisting -); - -Then( - /^I expect that element "([^"]*)?"( not)* contains the same text as element "([^"]*)?"$/, - compareText -); - -Then( - /^I expect that (button|element) "([^"]*)?"( not)* matches the text "([^"]*)?"$/, - checkEqualsText -); - -Then( - /^I expect that (button|element|container) "([^"]*)?"( not)* contains the text "([^"]*)?"$/, - checkContainsText -); - -Then( - /^I expect that (button|element) "([^"]*)?"( not)* contains any text$/, - checkContainsAnyText -); - -Then( - /^I expect that (button|element) "([^"]*)?" is( not)* empty$/, - checkIsEmpty -); - -Then( - /^I expect that the url is( not)* "([^"]*)?"$/, - checkURL -); - -Then( - /^I expect that the path is( not)* "([^"]*)?"$/, - checkURLPath -); - -Then( - /^I expect the url to( not)* contain "([^"]*)?"$/, - checkInURLPath -); - -Then( - /^I expect that the( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"$/, - checkProperty -); - -Then( - /^I expect that the( css)* attribute "([^"]*)?" from element "([^"]*)?" does( not)* contain "([^"]*)?"$/, - checkPropertyContains -); - -Then( - /^I expect that the font( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"$/, - checkFontProperty -); - -Then( - /^I expect that checkbox "([^"]*)?" is( not)* checked$/, - checkSelected -); - -Then( - /^I expect that element "([^"]*)?" is( not)* selected$/, - checkSelected -); - -Then( - /^I expect that element "([^"]*)?" is( not)* enabled$/, - isEnabled -); - -Then( - /^I expect that cookie "([^"]*)?"( not)* contains "([^"]*)?"$/, - checkCookieContent -); - -Then( - /^I expect that cookie "([^"]*)?"( not)* exists$/, - checkCookieExists -); - -Then( - /^I expect that element "([^"]*)?" is( not)* ([\d]+)px (broad|tall)$/, - checkDimension -); - -Then( - /^I expect that element "([^"]*)?" is( not)* positioned at ([\d+.?\d*]+)px on the (x|y) axis$/, - checkOffset -); - -Then( - /^I expect that element "([^"]*)?" (has|does not have) the class "([^"]*)?"$/, - checkClass -); - -Then( - /^I expect a new (window|tab) has( not)* been opened$/, - checkNewWindow -); - -Then( - /^I expect the url "([^"]*)?" is opened in a new (tab|window)$/, - checkIsOpenedInNewWindow -); - -Then( - /^I expect that element "([^"]*)?" is( not)* focused$/, - checkFocus -); - -Then( - /^I wait on element "([^"]*)?"(?: for (\d+)ms)*(?: to( not)* (be checked|be enabled|be selected|be displayed|contain a text|contain a value|exist))*$/, - { - wrapperOptions: { - retry: 3, - }, - }, - waitFor -); - -Then( - /^I expect that a (alertbox|confirmbox|prompt) is( not)* opened$/, - checkModal -); - -Then( - /^I expect that a (alertbox|confirmbox|prompt)( not)* contains the text "([^"]*)?"$/, - checkModalText -); diff --git a/src/steps/when.js b/src/steps/when.js deleted file mode 100644 index b0d16b8..0000000 --- a/src/steps/when.js +++ /dev/null @@ -1,128 +0,0 @@ - -import { When } from '@cucumber/cucumber'; -import switchToFrame from '../support/action/switchToFrame'; -import returnToParentFrame from '../support/action/returnToParentFrame'; -import clearInputField from '../support/action/clearInputField'; -import clickElement from '../support/action/clickElement'; -import closeLastOpenedWindow from '../support/action/closeLastOpenedWindow'; -import deleteCookies from '../support/action/deleteCookies'; -import dragElement from '../support/action/dragElement'; -import focusLastOpenedWindow from '../support/action/focusLastOpenedWindow'; -import handleModal from '../support/action/handleModal'; -import moveTo from '../support/action/moveTo'; -import pause from '../support/action/pause'; -import pressButton from '../support/action/pressButton'; -import scroll from '../support/action/scroll'; -import selectOption from '../support/action/selectOption'; -import selectOptionByIndex from '../support/action/selectOptionByIndex'; -import setCookie from '../support/action/setCookie'; -import setInputField from '../support/action/setInputField'; -import setPromptText from '../support/action/setPromptText'; -import setRandomEmailInputField from '../support/action/setRandomEmailInputField'; -import setRandomNameInputField from "../support/action/setRandomNameInputField"; -import repeatInputField from "../support/action/repeatInputField"; - -When( - /^I (add|set) a random email to the inputfield "([^"]*)?"$/, - setRandomEmailInputField -); - -When( - /^I (add|set) a random name to the inputfield "([^"]*)?"$/, - setRandomNameInputField -); - -When( - /^I (click|doubleclick) on the (link|button|element) "([^"]*)?"$/, - clickElement -); - -When( - /^I (add|set) "([^"]*)?" to the inputfield "([^"]*)?"$/, - setInputField -); - -When( - /^I clear the inputfield "([^"]*)?"$/, - clearInputField -); - -When( - /^I drag element "([^"]*)?" to element "([^"]*)?"$/, - dragElement -); - -When( - /^I pause for (\d+)ms$/, - pause -); - -When( - /^I set a cookie "([^"]*)?" with the content "([^"]*)?"$/, - setCookie -); - -When( - /^I delete the cookie "([^"]*)?"$/, - deleteCookies -); - -When( - /^I press "([^"]*)?"$/, - pressButton -); - -When( - /^I (accept|dismiss) the (alertbox|confirmbox|prompt)$/, - handleModal -); - -When( - /^I enter "([^"]*)?" into the prompt$/, - setPromptText -); - -When( - /^I scroll to element "([^"]*)?"$/, - scroll -); - -When( - /^I close the last opened (window|tab)$/, - closeLastOpenedWindow -); - -When( - /^I focus the last opened (window|tab)$/, - focusLastOpenedWindow -); - -When( - /^I select the (\d+)(st|nd|rd|th) option for element "([^"]*)?"$/, - selectOptionByIndex -); - -When( - /^I select the option with the (name|value|text) "([^"]*)?" for element "([^"]*)?"$/, - selectOption -); - -When( - /^I move to element "([^"]*)?"(?: with an offset of (\d+),(\d+))*$/, - moveTo -); - -When( - /^I switch to the iframe "([^"]*)?"$/, - switchToFrame -); - -When( - /^I return to the parent iframe$/, - returnToParentFrame -); - -When( - /^I repeat the text in inputfield "([^"]*)?" in the inputfield "([^"]*)?"$/, - repeatInputField - ); \ No newline at end of file diff --git a/src/support/action/clearInputField.js b/src/support/action/clearInputField.js index 06adc27..2f2a8aa 100644 --- a/src/support/action/clearInputField.js +++ b/src/support/action/clearInputField.js @@ -2,6 +2,6 @@ * Clear a given input field (placeholder for WDIO's clearElement) * @param {String} selector Element selector */ -export default (selector) => { - $(selector).clearValue(); +export default async (selector) => { + await $(selector).clearValue(); }; diff --git a/src/support/action/clickElement.js b/src/support/action/clickElement.js index df41de3..e27bc07 100644 --- a/src/support/action/clickElement.js +++ b/src/support/action/clickElement.js @@ -6,7 +6,7 @@ import checkIfElementExists from '../lib/checkIfElementExists'; * @param {String} type Type of the element (link or selector) * @param {String} selector Element selector */ -export default (action, type, selector) => { +export default async (action, type, selector) => { /** * Element to perform the action on * @type {String} @@ -21,5 +21,5 @@ export default (action, type, selector) => { checkIfElementExists(selector2); - $(selector2)[method](); + await selector2[method](); }; diff --git a/src/support/action/closeAllButFirstTab.js b/src/support/action/closeAllButFirstTab.js index bd89564..eca91c1 100644 --- a/src/support/action/closeAllButFirstTab.js +++ b/src/support/action/closeAllButFirstTab.js @@ -3,7 +3,7 @@ * @param {String} obsolete Type of object to close (window or tab) */ /* eslint-disable no-unused-vars */ -export default (obsolete) => { +export default async (obsolete) => { /* eslint-enable no-unused-vars */ /** * Get all the window handles diff --git a/src/support/action/closeLastOpenedWindow.js b/src/support/action/closeLastOpenedWindow.js index 70ae035..48b3e45 100644 --- a/src/support/action/closeLastOpenedWindow.js +++ b/src/support/action/closeLastOpenedWindow.js @@ -3,7 +3,7 @@ * @param {String} obsolete Type of object to close (window or tab) */ /* eslint-disable no-unused-vars */ -export default (obsolete) => { +export default async (obsolete) => { /* eslint-enable no-unused-vars */ /** * The last opened window handle diff --git a/src/support/action/deleteCookies.js b/src/support/action/deleteCookies.js index fa9cd1a..35d5e21 100644 --- a/src/support/action/deleteCookies.js +++ b/src/support/action/deleteCookies.js @@ -2,6 +2,6 @@ * Delete a cookie * @param {String} name The name of the cookie to delete */ -export default (name) => { +export default async (name) => { browser.deleteCookies(name); }; diff --git a/src/support/action/dragElement.js b/src/support/action/dragElement.js index 77f68ff..2bb9ca2 100644 --- a/src/support/action/dragElement.js +++ b/src/support/action/dragElement.js @@ -3,6 +3,6 @@ * @param {String} selector The selector for the source element * @param {String} destination The selector for the destination element */ -export default (selector, destination) => { - $(selector).dragAndDrop($(destination)); +export default async (selector, destination) => { + await $(selector).dragAndDrop($(destination)); }; diff --git a/src/support/action/focusLastOpenedWindow.js b/src/support/action/focusLastOpenedWindow.js index fcc235c..b297b76 100644 --- a/src/support/action/focusLastOpenedWindow.js +++ b/src/support/action/focusLastOpenedWindow.js @@ -3,7 +3,7 @@ * @param {String} obsolete Type of object to focus to (window or tab) */ /* eslint-disable no-unused-vars */ -export default (obsolete) => { +export default async (obsolete) => { /* eslint-enable no-unused-vars */ /** * The last opened window diff --git a/src/support/action/handleModal.js b/src/support/action/handleModal.js index 1fcecf8..e4304bf 100644 --- a/src/support/action/handleModal.js +++ b/src/support/action/handleModal.js @@ -3,7 +3,7 @@ * @param {String} action Action to perform on the modal (accept, dismiss) * @param {String} modalType Type of modal (alertbox, confirmbox, prompt) */ -export default (action, modalType) => { +export default async (action, modalType) => { /** * The command to perform on the browser object * @type {String} diff --git a/src/support/action/moveTo.js b/src/support/action/moveTo.js index d66a75a..d37c780 100644 --- a/src/support/action/moveTo.js +++ b/src/support/action/moveTo.js @@ -4,7 +4,7 @@ * @param {String} x X coordinate to move to * @param {String} y Y coordinate to move to */ -export default (selector, x, y) => { +export default async (selector, x, y) => { /** * X coordinate * @type {Int} @@ -17,5 +17,5 @@ export default (selector, x, y) => { */ const intY = parseInt(y, 10) || undefined; - $(selector).moveTo(intX, intY); + await $(selector).moveTo(intX, intY); }; diff --git a/src/support/action/openWebsite.js b/src/support/action/openWebsite.js index 670c93a..fe1fe1f 100644 --- a/src/support/action/openWebsite.js +++ b/src/support/action/openWebsite.js @@ -3,7 +3,7 @@ * @param {String} type Type of navigation (getUrl or site) * @param {String} page The URL to navigate to */ -export default (type, page) => { +export default async (type, page) => { /** * The URL to navigate to * @type {String} diff --git a/src/support/action/pause.js b/src/support/action/pause.js index 80e19b8..d0b9958 100644 --- a/src/support/action/pause.js +++ b/src/support/action/pause.js @@ -2,7 +2,7 @@ * Pause execution for a given number of milliseconds * @param {String} ms Number of milliseconds to pause */ -export default (ms) => { +export default async (ms) => { /** * Number of milliseconds * @type {Int} diff --git a/src/support/action/pressButton.js b/src/support/action/pressButton.js index cfa6d81..03c140d 100644 --- a/src/support/action/pressButton.js +++ b/src/support/action/pressButton.js @@ -2,6 +2,6 @@ * Perform a key press * @param {String} key The key to press */ -export default (key) => { +export default async (key) => { browser.keys(key); }; diff --git a/src/support/action/repeatInputField.js b/src/support/action/repeatInputField.js index faff7e9..4441af1 100644 --- a/src/support/action/repeatInputField.js +++ b/src/support/action/repeatInputField.js @@ -5,22 +5,22 @@ * @param {String} element Element selector * @param {String} element Element selector */ - module.exports = (previousElement, element) => { +module.exports = (previousElement, element) => { let command = 'getValue'; - - var value = $(previousElement)[command](); - - console.log(value); - - let checkValue = value; - - if (!value) { - checkValue = ''; - } - - let commandSet = 'setValue'; - - $(element)[commandSet](checkValue); - - }; \ No newline at end of file + + let value = await $(previousElement)[command](); + + console.log(value); + + let checkValue = value; + + if (!value) { + checkValue = ''; + } + + let commandSet = 'setValue'; + + await $(element)[commandSet](checkValue); + +}; \ No newline at end of file diff --git a/src/support/action/scroll.js b/src/support/action/scroll.js index 8638fc4..3cbefa3 100644 --- a/src/support/action/scroll.js +++ b/src/support/action/scroll.js @@ -2,6 +2,6 @@ * Scroll the page to the given element * @param {String} selector Element selector */ -export default (selector) => { - $(selector).scrollIntoView(); +export default async (selector) => { + await $(selector).scrollIntoView(); }; diff --git a/src/support/action/selectOption.js b/src/support/action/selectOption.js index 95eb393..4a46384 100644 --- a/src/support/action/selectOption.js +++ b/src/support/action/selectOption.js @@ -5,7 +5,7 @@ * @param {String} selectionValue Value to select by * @param {String} selector Element selector */ -export default (selectionType, selectionValue, selector) => { +export default async (selectionType, selectionValue, selector) => { /** * The method to use for selecting the option * @type {String} @@ -42,5 +42,5 @@ export default (selectionType, selectionValue, selector) => { } } - $(selector)[command](...commandArguments); + await $(selector)[command](...commandArguments); }; diff --git a/src/support/action/selectOptionByIndex.js b/src/support/action/selectOptionByIndex.js index 0355b0f..b87f4cb 100644 --- a/src/support/action/selectOptionByIndex.js +++ b/src/support/action/selectOptionByIndex.js @@ -6,12 +6,12 @@ * * @todo merge with selectOption */ -export default (index, obsolete, selector) => { +export default async (index, obsolete, selector) => { /** * The index of the option to select * @type {Int} */ const optionIndex = parseInt(index, 10); - $(selector).selectByIndex(optionIndex); + await $(selector).selectByIndex(optionIndex); }; diff --git a/src/support/action/setCookie.js b/src/support/action/setCookie.js index e550839..3e19b8c 100644 --- a/src/support/action/setCookie.js +++ b/src/support/action/setCookie.js @@ -4,7 +4,7 @@ * @param {String} cookieName The name of the cookie * @param {String} cookieContent The value of the cookie */ -export default (cookieName, cookieContent) => { +export default async (cookieName, cookieContent) => { browser.setCookies({ name: cookieName, value: cookieContent, diff --git a/src/support/action/setInputField.js b/src/support/action/setInputField.js index 5a9496f..550ceae 100644 --- a/src/support/action/setInputField.js +++ b/src/support/action/setInputField.js @@ -7,7 +7,7 @@ import checkIfElementExists from '../lib/checkIfElementExists'; * @param {String} value The value to set the selector to * @param {String} selector Element selector */ -export default (method, value, selector) => { +export default async (method, value, selector) => { /** * The command to perform on the browser object (addValue or setValue) * @type {String} @@ -22,7 +22,7 @@ export default (method, value, selector) => { checkValue = ''; } - $(selector)[command](checkValue); + await $(selector)[command](checkValue); if (!global.world){ global.world={}; diff --git a/src/support/action/setPromptText.js b/src/support/action/setPromptText.js index b42bef0..0668ae9 100644 --- a/src/support/action/setPromptText.js +++ b/src/support/action/setPromptText.js @@ -2,7 +2,7 @@ * Set the text of the current prompt * @param {String} modalText The text to set to the prompt */ -export default (modalText) => { +export default async (modalText) => { try { browser.sendAlertText(modalText); } catch (e) { diff --git a/src/support/action/setRandomEmailInputField.js b/src/support/action/setRandomEmailInputField.js index f0f9519..5f63983 100644 --- a/src/support/action/setRandomEmailInputField.js +++ b/src/support/action/setRandomEmailInputField.js @@ -9,8 +9,8 @@ import setInputField from './setInputField'; */ module.exports = (method, element) => { - var date = Date.now().toString(); - var value = "qa.qustodio.e2etest+" + date + "@qustodio.com"; + let date = browser.now().toString(); + let value = "qa.qustodio.e2etest+" + date + "@qustodio.com"; setInputField(method, value, element); }; \ No newline at end of file diff --git a/src/support/action/setRandomNameInputField.js b/src/support/action/setRandomNameInputField.js index 049289e..f067ff5 100644 --- a/src/support/action/setRandomNameInputField.js +++ b/src/support/action/setRandomNameInputField.js @@ -8,8 +8,8 @@ import setInputField from "./setInputField"; */ module.exports = (method, element) => { - var date = Date.now().toString(); - var value = "RandomName " + date; + let date = browser.now().toString(); + let value = "RandomName " + date; setInputField(method, value, element); }; \ No newline at end of file diff --git a/src/support/action/setWindowSize.js b/src/support/action/setWindowSize.js index fc522e0..af8f673 100644 --- a/src/support/action/setWindowSize.js +++ b/src/support/action/setWindowSize.js @@ -3,7 +3,7 @@ * @param {String} screenWidth The width of the window to resize to * @param {String} screenHeight The height of the window to resize to */ -export default (screenWidth, screenHeight) => { +export default async (screenWidth, screenHeight) => { browser.setWindowSize( parseInt(screenWidth, 10), parseInt(screenHeight, 10) diff --git a/src/support/action/switchToFrame.js b/src/support/action/switchToFrame.js index 6675561..1a47dc1 100644 --- a/src/support/action/switchToFrame.js +++ b/src/support/action/switchToFrame.js @@ -3,7 +3,7 @@ * @param {String} name of the iframe */ module.exports = (iframeSelectorId) => { - var iframeId = '#' + iframeSelectorId; - var iframe = $(iframeId) + let iframeId = '#' + iframeSelectorId; + let iframe = $(iframeId) browser.switchToFrame(iframe); }; \ No newline at end of file diff --git a/src/support/action/waitFor.js b/src/support/action/waitFor.js index edeed71..e7ec303 100644 --- a/src/support/action/waitFor.js +++ b/src/support/action/waitFor.js @@ -6,7 +6,7 @@ * @param {String} state State to check for (default * existence) */ -export default (selector, ms, falseState, state) => { +export default async (selector, ms, falseState, state) => { /** * Maximum number of milliseconds to wait, default 10000 * @type {Int} @@ -46,5 +46,5 @@ export default (selector, ms, falseState, state) => { boolFalseState = false; } - $(selector)[command](intMs, boolFalseState); + await $(selector)[command](intMs, boolFalseState); }; diff --git a/src/support/action/waitForDisplayed.js b/src/support/action/waitForDisplayed.js index d548907..bded667 100644 --- a/src/support/action/waitForDisplayed.js +++ b/src/support/action/waitForDisplayed.js @@ -6,12 +6,12 @@ * * @todo merge with waitfor */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * Maximum number of milliseconds to wait for * @type {Int} */ const ms = 10000; - $(selector).waitForDisplayed(ms, !!falseCase); + await $(selector).waitForDisplayed(ms, !!falseCase); }; diff --git a/src/support/check/checkClass.js b/src/support/check/checkClass.js index 67a17c2..047cbd6 100644 --- a/src/support/check/checkClass.js +++ b/src/support/check/checkClass.js @@ -5,20 +5,20 @@ * or not ('has', 'does not have') * @param {String} expectedClassName The class name to check */ -export default (selector, falseCase, expectedClassName) => { +export default async (selector, falseCase, expectedClassName) => { /** * List of all the classes of the element * @type {Array} */ - const classesList = $(selector).getAttribute('className').split(' '); + const classesList = await $(selector).getAttribute('className').split(' '); if (falseCase === 'does not have') { - expect(classesList).not.toContain( + await expect(classesList).not.toContain( expectedClassName, `Element ${selector} should not have the class ${expectedClassName}` ); } else { - expect(classesList).toContain( + await expect(classesList).toContain( expectedClassName, `Element ${selector} should have the class ${expectedClassName}` ); diff --git a/src/support/check/checkContainsAnyText.js b/src/support/check/checkContainsAnyText.js index 502b260..0e05630 100644 --- a/src/support/check/checkContainsAnyText.js +++ b/src/support/check/checkContainsAnyText.js @@ -5,7 +5,7 @@ * @param {String} falseCase Whether to check if the content contains * text or not */ -export default (elementType, selector, falseCase) => { +export default async (elementType, selector, falseCase) => { /** * The command to perform on the browser object * @type {String} @@ -14,7 +14,7 @@ export default (elementType, selector, falseCase) => { if ( elementType === 'button' - || $(selector).getAttribute('value') === null + || await $(selector).getAttribute('value') === null ) { command = 'getText'; } @@ -29,7 +29,7 @@ export default (elementType, selector, falseCase) => { * The text of the element * @type {String} */ - const text = $(selector)[command](); + const text = await $(selector)[command](); if (typeof falseCase === 'undefined') { boolFalseCase = false; @@ -38,8 +38,8 @@ export default (elementType, selector, falseCase) => { } if (boolFalseCase) { - expect(text).toBe(''); + await expect(text).toBe(''); } else { - expect(text).not.toBe(''); + await expect(text).not.toBe(''); } }; diff --git a/src/support/check/checkContainsText.js b/src/support/check/checkContainsText.js index 918c3ba..a2442a1 100644 --- a/src/support/check/checkContainsText.js +++ b/src/support/check/checkContainsText.js @@ -6,7 +6,7 @@ * the given text or not * @param {String} expectedText The text to check against */ -export default (elementType, selector, falseCase, expectedText) => { +export default async (elementType, selector, falseCase, expectedText) => { /** * The command to perform on the browser object * @type {String} @@ -15,7 +15,7 @@ export default (elementType, selector, falseCase, expectedText) => { if ( ['button', 'container'].includes(elementType) - || $(selector).getAttribute('value') === null + || await $(selector).getAttribute('value') === null ) { command = 'getText'; } @@ -36,9 +36,9 @@ export default (elementType, selector, falseCase, expectedText) => { * The text of the element * @type {String} */ - const elem = $(selector); + const elem = await $(selector); elem.waitForDisplayed(); - const text = elem[command](); + const text = await elem[command](); if (typeof expectedText === 'undefined') { stringExpectedText = falseCase; @@ -48,8 +48,8 @@ export default (elementType, selector, falseCase, expectedText) => { } if (boolFalseCase) { - expect(text.toLowerCase()).not.toContain(stringExpectedText.toLowerCase()); + await expect(text.toLowerCase()).not.toContain(stringExpectedText.toLowerCase()); } else { - expect(text.toLowerCase()).toContain(stringExpectedText.toLowerCase()); + await expect(text.toLowerCase()).toContain(stringExpectedText.toLowerCase()); } }; diff --git a/src/support/check/checkCookieContent.js b/src/support/check/checkCookieContent.js index 67dd03b..dbb070d 100644 --- a/src/support/check/checkCookieContent.js +++ b/src/support/check/checkCookieContent.js @@ -5,24 +5,24 @@ * or not * @param {String} expectedValue The value to check against */ -export default (name, falseCase, expectedValue) => { +export default async (name, falseCase, expectedValue) => { /** * The cookie retrieved from the browser object * @type {Object} */ const cookie = browser.getCookies(name)[0]; - expect(cookie.name).toBe( + await expect(cookie.name).toBe( name, `no cookie found with the name "${name}"` ); if (falseCase) { - expect(cookie.value).not.toBe( + await expect(cookie.value).not.toBe( expectedValue, `expected cookie "${name}" not to have value "${expectedValue}"` ); } else { - expect(cookie.value).toBe( + await expect(cookie.value).toBe( expectedValue, `expected cookie "${name}" to have value "${expectedValue}"` + ` but got "${cookie.value}"` diff --git a/src/support/check/checkCookieExists.js b/src/support/check/checkCookieExists.js index fd975e2..3f06049 100644 --- a/src/support/check/checkCookieExists.js +++ b/src/support/check/checkCookieExists.js @@ -4,7 +4,7 @@ * @param {[type]} falseCase Whether or not to check if the cookie exists or * not */ -export default (name, falseCase) => { +export default async (name, falseCase) => { /** * The cookie as retrieved from the browser * @type {Object} @@ -12,12 +12,12 @@ export default (name, falseCase) => { const cookie = browser.getCookies(name); if (falseCase) { - expect(cookie).toHaveLength( + await expect(cookie).toHaveLength( 0, `Expected cookie "${name}" not to exists but it does` ); } else { - expect(cookie).not.toHaveLength( + await expect(cookie).not.toHaveLength( 0, `Expected cookie "${name}" to exists but it does not` ); diff --git a/src/support/check/checkDimension.js b/src/support/check/checkDimension.js index 3b9b71e..6acdc40 100644 --- a/src/support/check/checkDimension.js +++ b/src/support/check/checkDimension.js @@ -6,12 +6,12 @@ * @param {String} expectedSize Expected size * @param {String} dimension Dimension to check (broad or tall) */ -export default (selector, falseCase, expectedSize, dimension) => { +export default async (selector, falseCase, expectedSize, dimension) => { /** * The size of the given element * @type {Object} */ - const elementSize = $(selector).getSize(); + const elementSize = await $(selector).getSize(); /** * Parsed size to check for @@ -37,13 +37,13 @@ export default (selector, falseCase, expectedSize, dimension) => { } if (falseCase) { - expect(originalSize).not.toBe( + await expect(originalSize).not.toBe( intExpectedSize, `Element "${selector}" should not have a ${label} of ` + `${intExpectedSize}px` ); } else { - expect(originalSize).toBe( + await expect(originalSize).toBe( intExpectedSize, `Element "${selector}" should have a ${label} of ` + `${intExpectedSize}px, but is ${originalSize}px` diff --git a/src/support/check/checkElementExists.js b/src/support/check/checkElementExists.js index fd5f18c..5f8935e 100644 --- a/src/support/check/checkElementExists.js +++ b/src/support/check/checkElementExists.js @@ -6,7 +6,7 @@ import checkIfElementExists from '../lib/checkIfElementExists'; * (an or no) * @param {String} selector Element selector */ -export default (isExisting, selector) => { +export default async (isExisting, selector) => { /** * Falsecase assertion * @type {Boolean} diff --git a/src/support/check/checkEqualsText.js b/src/support/check/checkEqualsText.js index 21afb69..1dcecbc 100644 --- a/src/support/check/checkEqualsText.js +++ b/src/support/check/checkEqualsText.js @@ -6,7 +6,7 @@ * given text or not * @param {String} expectedText The text to validate against */ -export default (elementType, selector, falseCase, expectedText) => { +export default async (elementType, selector, falseCase, expectedText) => { /** * The command to execute on the browser object * @type {String} @@ -15,7 +15,7 @@ export default (elementType, selector, falseCase, expectedText) => { if ( elementType === 'button' - || $(selector).getAttribute('value') === null + || await $(selector).getAttribute('value') === null ) { command = 'getText'; } @@ -48,8 +48,8 @@ export default (elementType, selector, falseCase, expectedText) => { if (boolFalseCase) { - expect(parsedExpectedText).not.toBe(text.toUpperCase()); + await expect(parsedExpectedText).not.toBe(text.toUpperCase()); } else { - expect(parsedExpectedText).toBe(text.toUpperCase()); + await expect(parsedExpectedText).toBe(text.toUpperCase()); } }; \ No newline at end of file diff --git a/src/support/check/checkFocus.js b/src/support/check/checkFocus.js index f3f4071..c8e9bfe 100644 --- a/src/support/check/checkFocus.js +++ b/src/support/check/checkFocus.js @@ -4,20 +4,20 @@ * @param {String} falseCase Whether to check if the given element has focus * or not */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * Value of the hasFocus function for the given element * @type {Boolean} */ - const hasFocus = $(selector).isFocused(); + const hasFocus = await $(selector).isFocused(); if (falseCase) { - expect(hasFocus).not.toBe( + await expect(hasFocus).not.toBe( true, 'Expected element to not be focused, but it is' ); } else { - expect(hasFocus).toBe( + await expect(hasFocus).toBe( true, 'Expected element to be focused, but it is not' ); diff --git a/src/support/check/checkFontProperty.js b/src/support/check/checkFontProperty.js index 5fdd0ec..896b943 100644 --- a/src/support/check/checkFontProperty.js +++ b/src/support/check/checkFontProperty.js @@ -8,7 +8,7 @@ * attribute matches or not * @param {String} expectedValue The value to match against */ -export default (isCSS, attrName, elem, falseCase, expectedValue) => { +export default async (isCSS, attrName, elem, falseCase, expectedValue) => { /** * The command to use for fetching the expected value * @type {String} @@ -36,13 +36,13 @@ export default (isCSS, attrName, elem, falseCase, expectedValue) => { } if (falseCase) { - expect(attributeValue).not.toBe( + await expect(attributeValue).not.toBe( expectedValue, `${attrType}: ${attrName} of element "${elem}" should not ` + `contain "${attributeValue}"` ); } else { - expect(attributeValue).toBe( + await expect(attributeValue).toBe( expectedValue, `${attrType}: ${attrName} of element "${elem}" should contain ` + `"${attributeValue}", but "${expectedValue}"` diff --git a/src/support/check/checkInURLPath.js b/src/support/check/checkInURLPath.js index 912595b..bb9ba68 100644 --- a/src/support/check/checkInURLPath.js +++ b/src/support/check/checkInURLPath.js @@ -4,7 +4,7 @@ * the URL path or not * @param {String} expectedUrlPart The string to check for */ -export default (falseCase, expectedUrlPart) => { +export default async (falseCase, expectedUrlPart) => { /** * The URL of the current browser window * @type {String} @@ -12,13 +12,13 @@ export default (falseCase, expectedUrlPart) => { const currentUrl = browser.getUrl(); if (falseCase) { - expect(currentUrl).not.toContain( + await expect(currentUrl).not.toContain( expectedUrlPart, `Expected URL "${currentUrl}" not to contain ` + `"${expectedUrlPart}"` ); } else { - expect(currentUrl).toContain( + await expect(currentUrl).toContain( expectedUrlPart, `Expected URL "${currentUrl}" to contain "${expectedUrlPart}"` ); diff --git a/src/support/check/checkIsEmpty.js b/src/support/check/checkIsEmpty.js index 5c5da3b..2c8a8e0 100644 --- a/src/support/check/checkIsEmpty.js +++ b/src/support/check/checkIsEmpty.js @@ -1,6 +1,6 @@ import checkContainsAnyText from './checkContainsAnyText'; -export default (elementType, element, falseCase) => { +export default async (elementType, element, falseCase) => { let newFalseCase = true; if (typeof falseCase === 'function') { diff --git a/src/support/check/checkIsOpenedInNewWindow.js b/src/support/check/checkIsOpenedInNewWindow.js index d0aa174..8456ec7 100644 --- a/src/support/check/checkIsOpenedInNewWindow.js +++ b/src/support/check/checkIsOpenedInNewWindow.js @@ -3,7 +3,7 @@ * @param {String} expectedUrl The URL to check for */ /* eslint-disable no-unused-vars */ -export default (expectedUrl, type) => { +export default async (expectedUrl, type) => { /* eslint-enable no-unused-vars */ /** * All the current window handles @@ -11,7 +11,7 @@ export default (expectedUrl, type) => { */ const windowHandles = browser.getWindowHandles(); - expect(windowHandles).not.toHaveLength(1, 'A popup was not opened'); + await expect(windowHandles).not.toHaveLength(1, 'A popup was not opened'); /** * The last opened window handle @@ -28,7 +28,7 @@ export default (expectedUrl, type) => { */ const windowUrl = browser.getUrl(); - expect(windowUrl).toContain( + await expect(windowUrl).toContain( expectedUrl, 'The popup has a incorrect getUrl' ); diff --git a/src/support/check/checkModal.js b/src/support/check/checkModal.js index f962a6e..ce5fcee 100644 --- a/src/support/check/checkModal.js +++ b/src/support/check/checkModal.js @@ -4,7 +4,7 @@ * confirmbox or prompt) * @param {String} falseState Whether to check if the modal was opened or not */ -export default (modalType, falseState) => { +export default async (modalType, falseState) => { /** * The text of the prompt * @type {String} @@ -15,14 +15,14 @@ export default (modalType, falseState) => { promptText = browser.getAlertText(); if (falseState) { - expect(promptText).not.toEqual( + await expect(promptText).not.toEqual( null, `A ${modalType} was opened when it shouldn't` ); } } catch (e) { if (!falseState) { - expect(promptText).toEqual( + await expect(promptText).toEqual( null, `A ${modalType} was not opened when it should have been` ); diff --git a/src/support/check/checkModalText.js b/src/support/check/checkModalText.js index fbf2635..b67974a 100644 --- a/src/support/check/checkModalText.js +++ b/src/support/check/checkModalText.js @@ -5,7 +5,7 @@ * @param {String} falseState Whether to check if the text matches or not * @param {String} expectedText The text to check against */ -export default (modalType, falseState, expectedText) => { +export default async (modalType, falseState, expectedText) => { try { /** * The text of the current modal @@ -14,13 +14,13 @@ export default (modalType, falseState, expectedText) => { const text = browser.getAlertText(); if (falseState) { - expect(text).not.toEqual( + await expect(text).not.toEqual( expectedText, `Expected the text of ${modalType} not to equal ` + `"${expectedText}"` ); } else { - expect(text).toEqual( + await expect(text).toEqual( expectedText, `Expected the text of ${modalType} to equal ` + `"${expectedText}", instead found "${text}"` diff --git a/src/support/check/checkNewWindow.js b/src/support/check/checkNewWindow.js index 0305336..061107f 100644 --- a/src/support/check/checkNewWindow.js +++ b/src/support/check/checkNewWindow.js @@ -4,7 +4,7 @@ * @param {String} falseCase Whether to check if a new window/tab was opened * or not */ -export default (obsolete, falseCase) => { +export default async (obsolete, falseCase) => { /** * The handles of all open windows/tabs * @type {Object} @@ -12,10 +12,10 @@ export default (obsolete, falseCase) => { const windowHandles = browser.getWindowHandles(); if (falseCase) { - expect(windowHandles) + await expect(windowHandles) .toHaveLength(1, 'A new window should not have been opened'); } else { - expect(windowHandles) + await expect(windowHandles) .not.toHaveLength(1, 'A new window has been opened'); } }; diff --git a/src/support/check/checkOffset.js b/src/support/check/checkOffset.js index daf61e8..faaf378 100644 --- a/src/support/check/checkOffset.js +++ b/src/support/check/checkOffset.js @@ -6,12 +6,12 @@ * @param {String} expectedPosition The position to check against * @param {String} axis The axis to check on (x or y) */ -export default (selector, falseCase, expectedPosition, axis) => { +export default async (selector, falseCase, expectedPosition, axis) => { /** * Get the location of the element on the given axis * @type {[type]} */ - const location = $(selector).getLocation(axis); + const location = await $(selector).getLocation(axis); /** * Parsed expected position @@ -20,13 +20,13 @@ export default (selector, falseCase, expectedPosition, axis) => { const intExpectedPosition = parseFloat(expectedPosition); if (falseCase) { - expect(location).not.toEqual( + await expect(location).not.toEqual( intExpectedPosition, `Element "${selector}" should not be positioned at ` + `${intExpectedPosition}px on the ${axis} axis` ); } else { - expect(location).toEqual( + await expect(location).toEqual( intExpectedPosition, `Element "${selector}" should be positioned at ` + `${intExpectedPosition}px on the ${axis} axis, but was found ` diff --git a/src/support/check/checkProperty.js b/src/support/check/checkProperty.js index e551905..6eae21c 100644 --- a/src/support/check/checkProperty.js +++ b/src/support/check/checkProperty.js @@ -8,7 +8,7 @@ * attribute matches or not * @param {String} expectedValue The value to match against */ -export default (isCSS, attrName, selector, falseCase, expectedValue) => { +export default async (isCSS, attrName, selector, falseCase, expectedValue) => { /** * The command to use for fetching the expected value * @type {String} @@ -25,7 +25,7 @@ export default (isCSS, attrName, selector, falseCase, expectedValue) => { * The actual attribute value * @type {Mixed} */ - let attributeValue = $(selector)[command](attrName); + let attributeValue = await $(selector)[command](attrName); // eslint-disable-next-line expectedValue = isFinite(expectedValue) ? @@ -40,13 +40,13 @@ export default (isCSS, attrName, selector, falseCase, expectedValue) => { attributeValue = attributeValue.value; } if (falseCase) { - expect(attributeValue).not.toEqual( + await expect(attributeValue).not.toEqual( expectedValue, `${attrType}: ${attrName} of element "${selector}" should ` + `not contain "${attributeValue}"` ); } else { - expect(attributeValue).toEqual( + await expect(attributeValue).toEqual( expectedValue, `${attrType}: ${attrName} of element "${selector}" should ` + `contain "${attributeValue}", but "${expectedValue}"` diff --git a/src/support/check/checkPropertyContains.js b/src/support/check/checkPropertyContains.js index 8dc6151..1195588 100644 --- a/src/support/check/checkPropertyContains.js +++ b/src/support/check/checkPropertyContains.js @@ -8,7 +8,7 @@ * attribute matches or not * @param {String} expectedValue The value to match against */ -export default (isCSS, attrName, selector, falseCase, expectedValue) => { +export default async (isCSS, attrName, selector, falseCase, expectedValue) => { /** * The command to use for fetching the expected value * @type {String} @@ -25,7 +25,7 @@ export default (isCSS, attrName, selector, falseCase, expectedValue) => { * The actual attribute value * @type {Mixed} */ - let attributeValue = $(selector)[command](attrName); + let attributeValue = await $(selector)[command](attrName); // eslint-disable-next-line expectedValue = isFinite(expectedValue) ? @@ -40,13 +40,13 @@ export default (isCSS, attrName, selector, falseCase, expectedValue) => { attributeValue = attributeValue.value; } if (falseCase) { - expect(attributeValue).not.toContain( + await expect(attributeValue).not.toContain( expectedValue, `${attrType}: ${attrName} of element "${selector}" should ` + `not contain "${attributeValue}"` ); } else { - expect(attributeValue).toContain( + await expect(attributeValue).toContain( expectedValue, `${attrType}: ${attrName} of element "${selector}" should ` + `contain "${attributeValue}", but "${expectedValue}"` diff --git a/src/support/check/checkSelected.js b/src/support/check/checkSelected.js index 3815af5..bcc3a75 100644 --- a/src/support/check/checkSelected.js +++ b/src/support/check/checkSelected.js @@ -4,18 +4,18 @@ * @param {String} falseCase Whether to check if the element is elected or * not */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * The selected state * @type {Boolean} */ - const isSelected = $(selector).isSelected(); + const isSelected = await $(selector).isSelected(); if (falseCase) { - expect(isSelected) + await expect(isSelected) .not.toEqual(true, `"${selector}" should not be selected`); } else { - expect(isSelected) + await expect(isSelected) .toEqual(true, `"${selector}" should be selected`); } }; diff --git a/src/support/check/checkTitle.js b/src/support/check/checkTitle.js index 58327a6..b1a208c 100644 --- a/src/support/check/checkTitle.js +++ b/src/support/check/checkTitle.js @@ -4,7 +4,7 @@ * expected value or not * @param {Type} expectedTitle The expected title */ -export default (falseCase, expectedTitle) => { +export default async (falseCase, expectedTitle) => { /** * The title of the current browser window * @type {String} @@ -12,12 +12,12 @@ export default (falseCase, expectedTitle) => { const title = browser.getTitle(); if (falseCase) { - expect(title).not.toEqual( + await expect(title).not.toEqual( expectedTitle, `Expected title not to be "${expectedTitle}"` ); } else { - expect(title).toEqual( + await expect(title).toEqual( expectedTitle, `Expected title to be "${expectedTitle}" but found "${title}"` ); diff --git a/src/support/check/checkTitleContains.js b/src/support/check/checkTitleContains.js index 97db78c..d3657fb 100644 --- a/src/support/check/checkTitleContains.js +++ b/src/support/check/checkTitleContains.js @@ -4,7 +4,7 @@ * expected value or not * @param {Type} expectedTitle The expected title */ -export default (falseCase, expectedTitle) => { +export default async (falseCase, expectedTitle) => { /** * The actual title of the current browser window * @type {String} @@ -12,12 +12,12 @@ export default (falseCase, expectedTitle) => { const title = browser.getTitle(); if (falseCase) { - expect(title).not.toContain( + await expect(title).not.toContain( expectedTitle, `Expected title not to contain "${expectedTitle}"` ); } else { - expect(title).toContain( + await expect(title).toContain( expectedTitle, `Expected title to contain "${expectedTitle}" but found "${title}"` ); diff --git a/src/support/check/checkURL.js b/src/support/check/checkURL.js index 07b7afd..66e22e2 100644 --- a/src/support/check/checkURL.js +++ b/src/support/check/checkURL.js @@ -4,7 +4,7 @@ * expected value or not * @param {String} expectedUrl The expected URL to check against */ -export default (falseCase, expectedUrl) => { +export default async (falseCase, expectedUrl) => { /** * The current browser window's URL * @type {String} @@ -12,10 +12,10 @@ export default (falseCase, expectedUrl) => { const currentUrl = browser.getUrl(); if (falseCase) { - expect(currentUrl) + await expect(currentUrl) .not.toEqual(expectedUrl, `expected url not to be "${currentUrl}"`); } else { - expect(currentUrl).toEqual( + await expect(currentUrl).toEqual( expectedUrl, `expected url to be "${expectedUrl}" but found ` + `"${currentUrl}"` diff --git a/src/support/check/checkURLPath.js b/src/support/check/checkURLPath.js index 0d91891..cbff8df 100644 --- a/src/support/check/checkURLPath.js +++ b/src/support/check/checkURLPath.js @@ -4,7 +4,7 @@ * expected value or not * @param {String} expectedPath The expected path to match against */ -export default (falseCase, expectedPath) => { +export default async (falseCase, expectedPath) => { /** * The URL of the current browser window * @type {String} @@ -20,10 +20,10 @@ export default (falseCase, expectedPath) => { currentUrl = currentUrl.replace(domain, ''); if (falseCase) { - expect(currentUrl) + await expect(currentUrl) .not.toEqual(expectedPath, `expected path not to be "${currentUrl}"`); } else { - expect(currentUrl).toEqual( + await expect(currentUrl).toEqual( expectedPath, `expected path to be "${expectedPath}" but found ` + `"${currentUrl}"` diff --git a/src/support/check/checkWithinViewport.js b/src/support/check/checkWithinViewport.js index 21d2675..559d2c8 100644 --- a/src/support/check/checkWithinViewport.js +++ b/src/support/check/checkWithinViewport.js @@ -4,20 +4,20 @@ * @param {String} falseCase Whether to check if the element is visible * within the current viewport or not */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * The state of visibility of the given element inside the viewport * @type {Boolean} */ - const isDisplayed = $(selector).isDisplayedInViewport(); + const isDisplayed = await $(selector).isDisplayedInViewport(); if (falseCase) { - expect(isDisplayed).not.toEqual( + await expect(isDisplayed).not.toEqual( true, `Expected element "${selector}" to be outside the viewport` ); } else { - expect(isDisplayed).toEqual( + await expect(isDisplayed).toEqual( true, `Expected element "${selector}" to be inside the viewport` ); diff --git a/src/support/check/compareText.js b/src/support/check/compareText.js index 7bb110f..970c298 100644 --- a/src/support/check/compareText.js +++ b/src/support/check/compareText.js @@ -5,26 +5,26 @@ * elements match or not * @param {String} selector2 Element selector for the second element */ -export default (selector1, falseCase, selector2) => { +export default async (selector1, falseCase, selector2) => { /** * The text of the first element * @type {String} */ - const text1 = $(selector1).getText(); + const text1 = await $(selector1).getText(); /** * The text of the second element * @type {String} */ - const text2 = $(selector2).getText(); + const text2 = await $(selector2).getText(); if (falseCase) { - expect(text1).not.toEqual( + await expect(text1).not.toEqual( text2, `Expected text not to be "${text1}"` ); } else { - expect(text1).toEqual( + await expect(text1).toEqual( text2, `Expected text to be "${text1}" but found "${text2}"` ); diff --git a/src/support/check/isDisplayed.js b/src/support/check/isDisplayed.js index 033b4b2..e2dd23c 100644 --- a/src/support/check/isDisplayed.js +++ b/src/support/check/isDisplayed.js @@ -3,20 +3,20 @@ * @param {String} selector Element selector * @param {String} falseCase Check for a visible or a hidden element */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * Visible state of the give element * @type {String} */ - const isDisplayed = $(selector).isDisplayed(); + const isDisplayed = await $(selector).isDisplayed(); if (falseCase) { - expect(isDisplayed).not.toEqual( + await expect(isDisplayed).not.toEqual( true, `Expected element "${selector}" not to be displayed` ); } else { - expect(isDisplayed).toEqual( + await expect(isDisplayed).toEqual( true, `Expected element "${selector}" to be displayed` ); diff --git a/src/support/check/isEnabled.js b/src/support/check/isEnabled.js index 45950a4..6198a80 100644 --- a/src/support/check/isEnabled.js +++ b/src/support/check/isEnabled.js @@ -4,20 +4,20 @@ * @param {String} falseCase Whether to check if the given selector * is enabled or not */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * The enabled state of the given selector * @type {Boolean} */ - const isEnabled = $(selector).isEnabled(); + const isEnabled = await $(selector).isEnabled(); if (falseCase) { - expect(isEnabled).not.toEqual( + await expect(isEnabled).not.toEqual( true, `Expected element "${selector}" not to be enabled` ); } else { - expect(isEnabled).toEqual( + await expect(isEnabled).toEqual( true, `Expected element "${selector}" to be enabled` ); diff --git a/src/support/check/isExisting.js b/src/support/check/isExisting.js index b752f7f..218cf3b 100644 --- a/src/support/check/isExisting.js +++ b/src/support/check/isExisting.js @@ -3,20 +3,20 @@ * @param {String} selector Element selector * @param {String} falseCase Whether to check if the element exists or not */ -export default (selector, falseCase) => { +export default async (selector, falseCase) => { /** * Elements found in the DOM * @type {Object} */ - const elements = $$(selector); + const elements = await $$(selector); if (falseCase) { - expect(elements).toHaveLength( + await expect(elements).toHaveLength( 0, `Expected element "${selector}" not to exist` ); } else { - expect(elements.length).toBeGreaterThan( + await expect(elements.length).toBeGreaterThan( 0, `Expected element "${selector}" to exist` ); diff --git a/src/support/lib/checkIfElementExists.js b/src/support/lib/checkIfElementExists.js index 649c6b2..fadfb9a 100644 --- a/src/support/lib/checkIfElementExists.js +++ b/src/support/lib/checkIfElementExists.js @@ -5,26 +5,26 @@ * @param {Number} exactly Check if the element exists exactly this number * of times */ -export default (selector, falseCase, exactly) => { +export default async (selector, falseCase, exactly) => { /** * The number of elements found in the DOM * @type {Int} */ - const nrOfElements = $$(selector); + const nrOfElements = await $$(selector); if (falseCase === true) { - expect(nrOfElements).toHaveLength( + await expect(nrOfElements).toHaveLength( 0, `Element with selector "${selector}" should not exist on the page` ); } else if (exactly) { - expect(nrOfElements).toHaveLength( + await expect(nrOfElements).toHaveLength( exactly, `Element with selector "${selector}" should exist exactly ` + `${exactly} time(s)` ); } else { - expect(nrOfElements.length).toBeGreaterThanOrEqual( + await expect(nrOfElements.length).toBeGreaterThanOrEqual( 1, `Element with selector "${selector}" should exist on the page` ); diff --git a/src/support/lib/checkIfElementExistsAtLeastOnce.js b/src/support/lib/checkIfElementExistsAtLeastOnce.js index 4fe0ff0..1a1f5b7 100644 --- a/src/support/lib/checkIfElementExistsAtLeastOnce.js +++ b/src/support/lib/checkIfElementExistsAtLeastOnce.js @@ -11,12 +11,12 @@ module.exports = (element, falsCase) => { const nrOfElements = browser.elements(element).value; if (falsCase === true) { - expect(nrOfElements).to.have.lengthOf( + await expect(nrOfElements).to.have.lengthOf( 0, `Element with selector "${element}" should not exist on the page` ); } else { - expect(nrOfElements).to.have.length.of.at.least( + await expect(nrOfElements).to.have.length.of.at.least( 1, `Element with selector "${element}" should exist on the page` ); diff --git a/wdio.conf.js b/wdio.conf.js index 74a0daf..9f87c4e 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -106,7 +106,7 @@ exports.config = { baseUrl: 'http://localhost:3000/#/login', // // Default timeout for all waitFor* commands. - waitforTimeout: 19000, + waitforTimeout: 99999, // // Default timeout in milliseconds for request // if browser driver or grid doesn't send response @@ -168,10 +168,8 @@ exports.config = { // (name) specify the profile to use profile: [], // (file/dir) require files before executing features - require: [ - './node_modules/qustodio-itui/src/steps/given.js', - './node_modules/qustodio-itui/src/steps/when.js', - './node_modules/qustodio-itui/src/steps/then.js', + require: [ + './src/steps/**/*.feature', ], // specify a custom snippet syntax snippetSyntax: undefined,