codeceptjs 3.5.12-beta.5 → 3.5.12-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/helper/Playwright.js +41 -22
- package/lib/helper/Puppeteer.js +23 -6
- package/lib/helper/WebDriver.js +23 -4
- package/lib/helper/errors/ElementAssertion.js +38 -0
- package/lib/locator.js +4 -13
- package/package.json +8 -10
- package/docs/advanced.md +0 -351
- package/docs/ai.md +0 -248
- package/docs/api.md +0 -323
- package/docs/basics.md +0 -979
- package/docs/bdd.md +0 -539
- package/docs/best.md +0 -237
- package/docs/books.md +0 -37
- package/docs/bootstrap.md +0 -135
- package/docs/build/ApiDataFactory.js +0 -410
- package/docs/build/Appium.js +0 -2027
- package/docs/build/Expect.js +0 -422
- package/docs/build/FileSystem.js +0 -228
- package/docs/build/GraphQL.js +0 -229
- package/docs/build/GraphQLDataFactory.js +0 -309
- package/docs/build/JSONResponse.js +0 -338
- package/docs/build/Mochawesome.js +0 -71
- package/docs/build/Nightmare.js +0 -2152
- package/docs/build/OpenAI.js +0 -126
- package/docs/build/Playwright.js +0 -5110
- package/docs/build/Protractor.js +0 -2706
- package/docs/build/Puppeteer.js +0 -3905
- package/docs/build/REST.js +0 -344
- package/docs/build/TestCafe.js +0 -2125
- package/docs/build/WebDriver.js +0 -4240
- package/docs/changelog.md +0 -2572
- package/docs/commands.md +0 -266
- package/docs/community-helpers.md +0 -58
- package/docs/configuration.md +0 -157
- package/docs/continuous-integration.md +0 -22
- package/docs/custom-helpers.md +0 -306
- package/docs/data.md +0 -379
- package/docs/detox.md +0 -235
- package/docs/docker.md +0 -136
- package/docs/email.md +0 -183
- package/docs/examples.md +0 -149
- package/docs/helpers/ApiDataFactory.md +0 -266
- package/docs/helpers/Appium.md +0 -1374
- package/docs/helpers/Detox.md +0 -586
- package/docs/helpers/Expect.md +0 -275
- package/docs/helpers/FileSystem.md +0 -152
- package/docs/helpers/GraphQL.md +0 -151
- package/docs/helpers/GraphQLDataFactory.md +0 -226
- package/docs/helpers/JSONResponse.md +0 -254
- package/docs/helpers/Mochawesome.md +0 -8
- package/docs/helpers/MockRequest.md +0 -377
- package/docs/helpers/Nightmare.md +0 -1305
- package/docs/helpers/OpenAI.md +0 -70
- package/docs/helpers/Playwright.md +0 -2759
- package/docs/helpers/Polly.md +0 -44
- package/docs/helpers/Protractor.md +0 -1769
- package/docs/helpers/Puppeteer-firefox.md +0 -86
- package/docs/helpers/Puppeteer.md +0 -2317
- package/docs/helpers/REST.md +0 -218
- package/docs/helpers/TestCafe.md +0 -1321
- package/docs/helpers/WebDriver.md +0 -2547
- package/docs/hooks.md +0 -340
- package/docs/index.md +0 -111
- package/docs/installation.md +0 -75
- package/docs/internal-api.md +0 -266
- package/docs/locators.md +0 -339
- package/docs/mobile-react-native-locators.md +0 -67
- package/docs/mobile.md +0 -338
- package/docs/pageobjects.md +0 -291
- package/docs/parallel.md +0 -400
- package/docs/playwright.md +0 -632
- package/docs/plugins.md +0 -1259
- package/docs/puppeteer.md +0 -316
- package/docs/quickstart.md +0 -162
- package/docs/react.md +0 -70
- package/docs/reports.md +0 -392
- package/docs/secrets.md +0 -36
- package/docs/shadow.md +0 -68
- package/docs/shared/keys.mustache +0 -31
- package/docs/shared/react.mustache +0 -1
- package/docs/testcafe.md +0 -174
- package/docs/translation.md +0 -247
- package/docs/tutorial.md +0 -271
- package/docs/typescript.md +0 -180
- package/docs/ui.md +0 -59
- package/docs/videos.md +0 -28
- package/docs/visual.md +0 -202
- package/docs/vue.md +0 -143
- package/docs/webapi/amOnPage.mustache +0 -11
- package/docs/webapi/appendField.mustache +0 -11
- package/docs/webapi/attachFile.mustache +0 -12
- package/docs/webapi/blur.mustache +0 -18
- package/docs/webapi/checkOption.mustache +0 -13
- package/docs/webapi/clearCookie.mustache +0 -9
- package/docs/webapi/clearField.mustache +0 -9
- package/docs/webapi/click.mustache +0 -25
- package/docs/webapi/clickLink.mustache +0 -8
- package/docs/webapi/closeCurrentTab.mustache +0 -7
- package/docs/webapi/closeOtherTabs.mustache +0 -8
- package/docs/webapi/dontSee.mustache +0 -11
- package/docs/webapi/dontSeeCheckboxIsChecked.mustache +0 -10
- package/docs/webapi/dontSeeCookie.mustache +0 -8
- package/docs/webapi/dontSeeCurrentUrlEquals.mustache +0 -10
- package/docs/webapi/dontSeeElement.mustache +0 -8
- package/docs/webapi/dontSeeElementInDOM.mustache +0 -8
- package/docs/webapi/dontSeeInCurrentUrl.mustache +0 -4
- package/docs/webapi/dontSeeInField.mustache +0 -11
- package/docs/webapi/dontSeeInSource.mustache +0 -8
- package/docs/webapi/dontSeeInTitle.mustache +0 -8
- package/docs/webapi/doubleClick.mustache +0 -13
- package/docs/webapi/downloadFile.mustache +0 -12
- package/docs/webapi/dragAndDrop.mustache +0 -9
- package/docs/webapi/dragSlider.mustache +0 -11
- package/docs/webapi/executeAsyncScript.mustache +0 -24
- package/docs/webapi/executeScript.mustache +0 -26
- package/docs/webapi/fillField.mustache +0 -16
- package/docs/webapi/focus.mustache +0 -13
- package/docs/webapi/forceClick.mustache +0 -28
- package/docs/webapi/forceRightClick.mustache +0 -18
- package/docs/webapi/grabAllWindowHandles.mustache +0 -7
- package/docs/webapi/grabAttributeFrom.mustache +0 -10
- package/docs/webapi/grabAttributeFromAll.mustache +0 -9
- package/docs/webapi/grabBrowserLogs.mustache +0 -9
- package/docs/webapi/grabCookie.mustache +0 -11
- package/docs/webapi/grabCssPropertyFrom.mustache +0 -11
- package/docs/webapi/grabCssPropertyFromAll.mustache +0 -10
- package/docs/webapi/grabCurrentUrl.mustache +0 -9
- package/docs/webapi/grabCurrentWindowHandle.mustache +0 -6
- package/docs/webapi/grabDataFromPerformanceTiming.mustache +0 -20
- package/docs/webapi/grabElementBoundingRect.mustache +0 -20
- package/docs/webapi/grabGeoLocation.mustache +0 -8
- package/docs/webapi/grabHTMLFrom.mustache +0 -10
- package/docs/webapi/grabHTMLFromAll.mustache +0 -9
- package/docs/webapi/grabNumberOfOpenTabs.mustache +0 -8
- package/docs/webapi/grabNumberOfVisibleElements.mustache +0 -9
- package/docs/webapi/grabPageScrollPosition.mustache +0 -8
- package/docs/webapi/grabPopupText.mustache +0 -5
- package/docs/webapi/grabSource.mustache +0 -8
- package/docs/webapi/grabTextFrom.mustache +0 -10
- package/docs/webapi/grabTextFromAll.mustache +0 -9
- package/docs/webapi/grabTitle.mustache +0 -8
- package/docs/webapi/grabValueFrom.mustache +0 -9
- package/docs/webapi/grabValueFromAll.mustache +0 -8
- package/docs/webapi/grabWebElement.mustache +0 -9
- package/docs/webapi/grabWebElements.mustache +0 -9
- package/docs/webapi/moveCursorTo.mustache +0 -12
- package/docs/webapi/openNewTab.mustache +0 -7
- package/docs/webapi/pressKey.mustache +0 -12
- package/docs/webapi/pressKeyDown.mustache +0 -12
- package/docs/webapi/pressKeyUp.mustache +0 -12
- package/docs/webapi/pressKeyWithKeyNormalization.mustache +0 -60
- package/docs/webapi/refreshPage.mustache +0 -6
- package/docs/webapi/resizeWindow.mustache +0 -6
- package/docs/webapi/rightClick.mustache +0 -14
- package/docs/webapi/saveElementScreenshot.mustache +0 -10
- package/docs/webapi/saveScreenshot.mustache +0 -12
- package/docs/webapi/say.mustache +0 -10
- package/docs/webapi/scrollIntoView.mustache +0 -11
- package/docs/webapi/scrollPageToBottom.mustache +0 -6
- package/docs/webapi/scrollPageToTop.mustache +0 -6
- package/docs/webapi/scrollTo.mustache +0 -12
- package/docs/webapi/see.mustache +0 -11
- package/docs/webapi/seeAttributesOnElements.mustache +0 -9
- package/docs/webapi/seeCheckboxIsChecked.mustache +0 -10
- package/docs/webapi/seeCookie.mustache +0 -8
- package/docs/webapi/seeCssPropertiesOnElements.mustache +0 -9
- package/docs/webapi/seeCurrentUrlEquals.mustache +0 -11
- package/docs/webapi/seeElement.mustache +0 -8
- package/docs/webapi/seeElementInDOM.mustache +0 -8
- package/docs/webapi/seeInCurrentUrl.mustache +0 -8
- package/docs/webapi/seeInField.mustache +0 -12
- package/docs/webapi/seeInPopup.mustache +0 -8
- package/docs/webapi/seeInSource.mustache +0 -7
- package/docs/webapi/seeInTitle.mustache +0 -8
- package/docs/webapi/seeNumberOfElements.mustache +0 -11
- package/docs/webapi/seeNumberOfVisibleElements.mustache +0 -10
- package/docs/webapi/seeTextEquals.mustache +0 -9
- package/docs/webapi/seeTitleEquals.mustache +0 -8
- package/docs/webapi/selectOption.mustache +0 -21
- package/docs/webapi/setCookie.mustache +0 -16
- package/docs/webapi/setGeoLocation.mustache +0 -12
- package/docs/webapi/switchTo.mustache +0 -9
- package/docs/webapi/switchToNextTab.mustache +0 -10
- package/docs/webapi/switchToPreviousTab.mustache +0 -10
- package/docs/webapi/type.mustache +0 -21
- package/docs/webapi/uncheckOption.mustache +0 -13
- package/docs/webapi/wait.mustache +0 -8
- package/docs/webapi/waitForClickable.mustache +0 -11
- package/docs/webapi/waitForDetached.mustache +0 -10
- package/docs/webapi/waitForElement.mustache +0 -11
- package/docs/webapi/waitForEnabled.mustache +0 -6
- package/docs/webapi/waitForFunction.mustache +0 -17
- package/docs/webapi/waitForInvisible.mustache +0 -10
- package/docs/webapi/waitForNumberOfTabs.mustache +0 -9
- package/docs/webapi/waitForText.mustache +0 -13
- package/docs/webapi/waitForValue.mustache +0 -10
- package/docs/webapi/waitForVisible.mustache +0 -10
- package/docs/webapi/waitInUrl.mustache +0 -9
- package/docs/webapi/waitNumberOfVisibleElements.mustache +0 -10
- package/docs/webapi/waitToHide.mustache +0 -10
- package/docs/webapi/waitUrlEquals.mustache +0 -10
- package/docs/webdriver.md +0 -701
- package/docs/wiki/Books-&-Posts.md +0 -27
- package/docs/wiki/Community-Helpers-&-Plugins.md +0 -53
- package/docs/wiki/Converting-Playwright-to-Istanbul-Coverage.md +0 -61
- package/docs/wiki/Examples.md +0 -145
- package/docs/wiki/Google-Summer-of-Code-(GSoC)-2020.md +0 -68
- package/docs/wiki/Home.md +0 -16
- package/docs/wiki/Migration-to-Appium-v2---CodeceptJS.md +0 -83
- package/docs/wiki/Release-Process.md +0 -24
- package/docs/wiki/Roadmap.md +0 -23
- package/docs/wiki/Tests.md +0 -1393
- package/docs/wiki/Upgrading-to-CodeceptJS-3.md +0 -153
- package/docs/wiki/Videos.md +0 -19
package/lib/helper/Playwright.js
CHANGED
|
@@ -47,6 +47,9 @@ const {
|
|
|
47
47
|
setRestartStrategy, restartsSession, restartsContext, restartsBrowser,
|
|
48
48
|
} = require('./extras/PlaywrightRestartOpts');
|
|
49
49
|
const { createValueEngine, createDisabledEngine } = require('./extras/PlaywrightPropEngine');
|
|
50
|
+
const {
|
|
51
|
+
seeElementError, dontSeeElementError, dontSeeElementInDOMError, seeElementInDOMError,
|
|
52
|
+
} = require('./errors/ElementAssertion');
|
|
50
53
|
|
|
51
54
|
const pathSeparator = path.sep;
|
|
52
55
|
|
|
@@ -1451,7 +1454,11 @@ class Playwright extends Helper {
|
|
|
1451
1454
|
async seeElement(locator) {
|
|
1452
1455
|
let els = await this._locate(locator);
|
|
1453
1456
|
els = await Promise.all(els.map(el => el.isVisible()));
|
|
1454
|
-
|
|
1457
|
+
try {
|
|
1458
|
+
return empty('visible elements').negate(els.filter(v => v).fill('ELEMENT'));
|
|
1459
|
+
} catch (e) {
|
|
1460
|
+
dontSeeElementError(locator);
|
|
1461
|
+
}
|
|
1455
1462
|
}
|
|
1456
1463
|
|
|
1457
1464
|
/**
|
|
@@ -1461,7 +1468,11 @@ class Playwright extends Helper {
|
|
|
1461
1468
|
async dontSeeElement(locator) {
|
|
1462
1469
|
let els = await this._locate(locator);
|
|
1463
1470
|
els = await Promise.all(els.map(el => el.isVisible()));
|
|
1464
|
-
|
|
1471
|
+
try {
|
|
1472
|
+
return empty('visible elements').assert(els.filter(v => v).fill('ELEMENT'));
|
|
1473
|
+
} catch (e) {
|
|
1474
|
+
seeElementError(locator);
|
|
1475
|
+
}
|
|
1465
1476
|
}
|
|
1466
1477
|
|
|
1467
1478
|
/**
|
|
@@ -1469,7 +1480,11 @@ class Playwright extends Helper {
|
|
|
1469
1480
|
*/
|
|
1470
1481
|
async seeElementInDOM(locator) {
|
|
1471
1482
|
const els = await this._locate(locator);
|
|
1472
|
-
|
|
1483
|
+
try {
|
|
1484
|
+
return empty('elements on page').negate(els.filter(v => v).fill('ELEMENT'));
|
|
1485
|
+
} catch (e) {
|
|
1486
|
+
dontSeeElementInDOMError(locator);
|
|
1487
|
+
}
|
|
1473
1488
|
}
|
|
1474
1489
|
|
|
1475
1490
|
/**
|
|
@@ -1477,7 +1492,11 @@ class Playwright extends Helper {
|
|
|
1477
1492
|
*/
|
|
1478
1493
|
async dontSeeElementInDOM(locator) {
|
|
1479
1494
|
const els = await this._locate(locator);
|
|
1480
|
-
|
|
1495
|
+
try {
|
|
1496
|
+
return empty('elements on a page').assert(els.filter(v => v).fill('ELEMENT'));
|
|
1497
|
+
} catch (e) {
|
|
1498
|
+
seeElementInDOMError(locator);
|
|
1499
|
+
}
|
|
1481
1500
|
}
|
|
1482
1501
|
|
|
1483
1502
|
/**
|
|
@@ -2974,27 +2993,27 @@ class Playwright extends Helper {
|
|
|
2974
2993
|
throw new Error('Failure in test automation. You use "I.grabRecordedNetworkTraffics", but "I.startRecordingTraffic" was never called before.');
|
|
2975
2994
|
}
|
|
2976
2995
|
|
|
2977
|
-
const
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
}
|
|
2996
|
+
const promises = this.requests.map(async (request) => {
|
|
2997
|
+
const resp = await request.response;
|
|
2998
|
+
let body;
|
|
2999
|
+
try {
|
|
3000
|
+
// There's no 'body' for some requests (redirect etc...)
|
|
3001
|
+
body = JSON.parse((await resp.body()).toString());
|
|
3002
|
+
} catch (e) {
|
|
3003
|
+
// only interested in JSON, not HTML responses.
|
|
3004
|
+
}
|
|
2987
3005
|
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
3006
|
+
return {
|
|
3007
|
+
url: resp.url(),
|
|
3008
|
+
response: {
|
|
3009
|
+
status: resp.status(),
|
|
3010
|
+
statusText: resp.statusText(),
|
|
2991
3011
|
body,
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2994
|
-
)
|
|
2995
|
-
await Promise.all(promises);
|
|
3012
|
+
},
|
|
3013
|
+
};
|
|
3014
|
+
});
|
|
2996
3015
|
|
|
2997
|
-
return
|
|
3016
|
+
return Promise.all(promises);
|
|
2998
3017
|
}
|
|
2999
3018
|
|
|
3000
3019
|
/**
|
package/lib/helper/Puppeteer.js
CHANGED
|
@@ -39,6 +39,9 @@ const findReact = require('./extras/React');
|
|
|
39
39
|
const { highlightElement } = require('./scripts/highlightElement');
|
|
40
40
|
const { blurElement } = require('./scripts/blurElement');
|
|
41
41
|
const { focusElement } = require('./scripts/focusElement');
|
|
42
|
+
const {
|
|
43
|
+
dontSeeElementError, seeElementError, dontSeeElementInDOMError, seeElementInDOMError,
|
|
44
|
+
} = require('./errors/ElementAssertion');
|
|
42
45
|
|
|
43
46
|
let puppeteer;
|
|
44
47
|
let perfTiming;
|
|
@@ -1038,8 +1041,11 @@ class Puppeteer extends Helper {
|
|
|
1038
1041
|
els = (await Promise.all(els.map(el => el.boundingBox() && el))).filter(v => v);
|
|
1039
1042
|
// Puppeteer visibility was ignored? | Remove when Puppeteer is fixed
|
|
1040
1043
|
els = await Promise.all(els.map(async el => (await el.evaluate(node => window.getComputedStyle(node).visibility !== 'hidden' && window.getComputedStyle(node).display !== 'none')) && el));
|
|
1041
|
-
|
|
1042
|
-
|
|
1044
|
+
try {
|
|
1045
|
+
return empty('visible elements').negate(els.filter(v => v).fill('ELEMENT'));
|
|
1046
|
+
} catch (e) {
|
|
1047
|
+
dontSeeElementError(locator);
|
|
1048
|
+
}
|
|
1043
1049
|
}
|
|
1044
1050
|
|
|
1045
1051
|
/**
|
|
@@ -1051,8 +1057,11 @@ class Puppeteer extends Helper {
|
|
|
1051
1057
|
els = (await Promise.all(els.map(el => el.boundingBox() && el))).filter(v => v);
|
|
1052
1058
|
// Puppeteer visibility was ignored? | Remove when Puppeteer is fixed
|
|
1053
1059
|
els = await Promise.all(els.map(async el => (await el.evaluate(node => window.getComputedStyle(node).visibility !== 'hidden' && window.getComputedStyle(node).display !== 'none')) && el));
|
|
1054
|
-
|
|
1055
|
-
|
|
1060
|
+
try {
|
|
1061
|
+
return empty('visible elements').assert(els.filter(v => v).fill('ELEMENT'));
|
|
1062
|
+
} catch (e) {
|
|
1063
|
+
seeElementError(locator);
|
|
1064
|
+
}
|
|
1056
1065
|
}
|
|
1057
1066
|
|
|
1058
1067
|
/**
|
|
@@ -1060,7 +1069,11 @@ class Puppeteer extends Helper {
|
|
|
1060
1069
|
*/
|
|
1061
1070
|
async seeElementInDOM(locator) {
|
|
1062
1071
|
const els = await this._locate(locator);
|
|
1063
|
-
|
|
1072
|
+
try {
|
|
1073
|
+
return empty('elements on page').negate(els.filter(v => v).fill('ELEMENT'));
|
|
1074
|
+
} catch (e) {
|
|
1075
|
+
dontSeeElementInDOMError(locator);
|
|
1076
|
+
}
|
|
1064
1077
|
}
|
|
1065
1078
|
|
|
1066
1079
|
/**
|
|
@@ -1068,7 +1081,11 @@ class Puppeteer extends Helper {
|
|
|
1068
1081
|
*/
|
|
1069
1082
|
async dontSeeElementInDOM(locator) {
|
|
1070
1083
|
const els = await this._locate(locator);
|
|
1071
|
-
|
|
1084
|
+
try {
|
|
1085
|
+
return empty('elements on a page').assert(els.filter(v => v).fill('ELEMENT'));
|
|
1086
|
+
} catch (e) {
|
|
1087
|
+
seeElementInDOMError(locator);
|
|
1088
|
+
}
|
|
1072
1089
|
}
|
|
1073
1090
|
|
|
1074
1091
|
/**
|
package/lib/helper/WebDriver.js
CHANGED
|
@@ -32,6 +32,9 @@ const { highlightElement } = require('./scripts/highlightElement');
|
|
|
32
32
|
const store = require('../store');
|
|
33
33
|
const { focusElement } = require('./scripts/focusElement');
|
|
34
34
|
const { blurElement } = require('./scripts/blurElement');
|
|
35
|
+
const {
|
|
36
|
+
dontSeeElementError, seeElementError, seeElementInDOMError, dontSeeElementInDOMError,
|
|
37
|
+
} = require('./errors/ElementAssertion');
|
|
35
38
|
|
|
36
39
|
const SHADOW = 'shadow';
|
|
37
40
|
const webRoot = 'body';
|
|
@@ -1461,7 +1464,11 @@ class WebDriver extends Helper {
|
|
|
1461
1464
|
const res = await this._locate(locator, true);
|
|
1462
1465
|
assertElementExists(res, locator);
|
|
1463
1466
|
const selected = await forEachAsync(res, async el => el.isDisplayed());
|
|
1464
|
-
|
|
1467
|
+
try {
|
|
1468
|
+
return truth(`elements of ${(new Locator(locator))}`, 'to be seen').assert(selected);
|
|
1469
|
+
} catch (e) {
|
|
1470
|
+
dontSeeElementError(locator);
|
|
1471
|
+
}
|
|
1465
1472
|
}
|
|
1466
1473
|
|
|
1467
1474
|
/**
|
|
@@ -1474,7 +1481,11 @@ class WebDriver extends Helper {
|
|
|
1474
1481
|
return truth(`elements of ${(new Locator(locator))}`, 'to be seen').negate(false);
|
|
1475
1482
|
}
|
|
1476
1483
|
const selected = await forEachAsync(res, async el => el.isDisplayed());
|
|
1477
|
-
|
|
1484
|
+
try {
|
|
1485
|
+
return truth(`elements of ${(new Locator(locator))}`, 'to be seen').negate(selected);
|
|
1486
|
+
} catch (e) {
|
|
1487
|
+
seeElementError(locator);
|
|
1488
|
+
}
|
|
1478
1489
|
}
|
|
1479
1490
|
|
|
1480
1491
|
/**
|
|
@@ -1483,7 +1494,11 @@ class WebDriver extends Helper {
|
|
|
1483
1494
|
*/
|
|
1484
1495
|
async seeElementInDOM(locator) {
|
|
1485
1496
|
const res = await this._res(locator);
|
|
1486
|
-
|
|
1497
|
+
try {
|
|
1498
|
+
return empty('elements').negate(res);
|
|
1499
|
+
} catch (e) {
|
|
1500
|
+
dontSeeElementInDOMError(locator);
|
|
1501
|
+
}
|
|
1487
1502
|
}
|
|
1488
1503
|
|
|
1489
1504
|
/**
|
|
@@ -1492,7 +1507,11 @@ class WebDriver extends Helper {
|
|
|
1492
1507
|
*/
|
|
1493
1508
|
async dontSeeElementInDOM(locator) {
|
|
1494
1509
|
const res = await this._res(locator);
|
|
1495
|
-
|
|
1510
|
+
try {
|
|
1511
|
+
return empty('elements').assert(res);
|
|
1512
|
+
} catch (e) {
|
|
1513
|
+
seeElementInDOMError(locator);
|
|
1514
|
+
}
|
|
1496
1515
|
}
|
|
1497
1516
|
|
|
1498
1517
|
/**
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const Locator = require('../../locator');
|
|
2
|
+
|
|
3
|
+
const prefixMessage = 'Element';
|
|
4
|
+
|
|
5
|
+
function seeElementError(locator) {
|
|
6
|
+
if (typeof locator === 'object') {
|
|
7
|
+
locator = JSON.stringify(locator);
|
|
8
|
+
}
|
|
9
|
+
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is still visible on page.`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function seeElementInDOMError(locator) {
|
|
13
|
+
if (typeof locator === 'object') {
|
|
14
|
+
locator = JSON.stringify(locator);
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is still seen in DOM.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function dontSeeElementError(locator) {
|
|
20
|
+
if (typeof locator === 'object') {
|
|
21
|
+
locator = JSON.stringify(locator);
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is not visible on page.`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function dontSeeElementInDOMError(locator) {
|
|
27
|
+
if (typeof locator === 'object') {
|
|
28
|
+
locator = JSON.stringify(locator);
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is not seen in DOM.`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
seeElementError,
|
|
35
|
+
dontSeeElementError,
|
|
36
|
+
seeElementInDOMError,
|
|
37
|
+
dontSeeElementInDOMError,
|
|
38
|
+
};
|
package/lib/locator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const cssToXPath = require('csstoxpath');
|
|
2
2
|
const { sprintf } = require('sprintf-js');
|
|
3
3
|
|
|
4
4
|
const { xpathLocator } = require('./utils');
|
|
@@ -162,17 +162,8 @@ class Locator {
|
|
|
162
162
|
* @returns {string}
|
|
163
163
|
*/
|
|
164
164
|
toXPath(pseudoSelector = '') {
|
|
165
|
-
const locator = `${this.value}${pseudoSelector}`;
|
|
166
|
-
const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang'];
|
|
167
|
-
|
|
168
|
-
if (limitation.some(item => locator.includes(item))) {
|
|
169
|
-
cssToXPath = require('css-to-xpath');
|
|
170
|
-
} else {
|
|
171
|
-
cssToXPath = require('csstoxpath');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
165
|
if (this.isXPath()) return this.value;
|
|
175
|
-
if (this.isCSS()) return cssToXPath(
|
|
166
|
+
if (this.isCSS()) return cssToXPath(`${this.value}${pseudoSelector}`);
|
|
176
167
|
|
|
177
168
|
throw new Error('Can\'t be converted to XPath');
|
|
178
169
|
}
|
|
@@ -259,7 +250,7 @@ class Locator {
|
|
|
259
250
|
*/
|
|
260
251
|
withText(text) {
|
|
261
252
|
text = xpathLocator.literal(text);
|
|
262
|
-
const xpath =
|
|
253
|
+
const xpath = this.toXPath(`:text-contains-case(${text})`);
|
|
263
254
|
return new Locator({ xpath });
|
|
264
255
|
}
|
|
265
256
|
|
|
@@ -270,7 +261,7 @@ class Locator {
|
|
|
270
261
|
*/
|
|
271
262
|
withTextEquals(text) {
|
|
272
263
|
text = xpathLocator.literal(text);
|
|
273
|
-
const xpath =
|
|
264
|
+
const xpath = this.toXPath(`:text-case(${text})`);
|
|
274
265
|
return new Locator({ xpath });
|
|
275
266
|
}
|
|
276
267
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeceptjs",
|
|
3
|
-
"version": "3.5.12-beta.
|
|
3
|
+
"version": "3.5.12-beta.6",
|
|
4
4
|
"description": "Supercharged End 2 End Testing Framework for NodeJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acceptance",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"bin",
|
|
26
|
-
"docs",
|
|
27
26
|
"lib",
|
|
28
27
|
"translations",
|
|
29
28
|
"typings/**/*.d.ts"
|
|
@@ -77,15 +76,14 @@
|
|
|
77
76
|
"axios": "1.6.3",
|
|
78
77
|
"chai": "4.3.8",
|
|
79
78
|
"chai-deep-match": "1.2.1",
|
|
80
|
-
"chai-exclude": "2.1.0",
|
|
81
|
-
"chai-json-schema": "1.5.1",
|
|
82
|
-
"chai-json-schema-ajv": "5.2.4",
|
|
83
|
-
"chai-match-pattern": "1.3.0",
|
|
84
|
-
"chai-string": "1.5.0",
|
|
79
|
+
"chai-exclude": "^2.1.0",
|
|
80
|
+
"chai-json-schema": "^1.5.1",
|
|
81
|
+
"chai-json-schema-ajv": "^5.2.4",
|
|
82
|
+
"chai-match-pattern": "^1.3.0",
|
|
83
|
+
"chai-string": "^1.5.0",
|
|
85
84
|
"chalk": "4.1.2",
|
|
86
85
|
"commander": "11.1.0",
|
|
87
86
|
"cross-spawn": "7.0.3",
|
|
88
|
-
"css-to-xpath": "0.1.0",
|
|
89
87
|
"csstoxpath": "1.6.0",
|
|
90
88
|
"devtools": "8.27.2",
|
|
91
89
|
"envinfo": "7.11.0",
|
|
@@ -94,7 +92,7 @@
|
|
|
94
92
|
"fn-args": "4.0.0",
|
|
95
93
|
"fs-extra": "11.2.0",
|
|
96
94
|
"glob": "6.0.1",
|
|
97
|
-
"html-minifier-terser": "7.2.0",
|
|
95
|
+
"html-minifier-terser": "^7.2.0",
|
|
98
96
|
"inquirer": "6.5.2",
|
|
99
97
|
"joi": "17.11.0",
|
|
100
98
|
"js-beautify": "1.14.11",
|
|
@@ -120,7 +118,7 @@
|
|
|
120
118
|
"@faker-js/faker": "7.6.0",
|
|
121
119
|
"@pollyjs/adapter-puppeteer": "6.0.6",
|
|
122
120
|
"@pollyjs/core": "5.1.0",
|
|
123
|
-
"@types/chai": "4.3.7",
|
|
121
|
+
"@types/chai": "^4.3.7",
|
|
124
122
|
"@types/inquirer": "9.0.3",
|
|
125
123
|
"@types/node": "20.10.7",
|
|
126
124
|
"@wdio/sauce-service": "8.27.0",
|