You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Custom Locator Strategies](#custom-locators): by data attributes or whatever you prefer.
15
15
*[Shadow DOM](/shadow): to access shadow dom elements
16
16
*[React](/react): to access React elements by component names and props
17
+
* Playwright: to access locator supported by Playwright, namely [_react](https://playwright.dev/docs/other-locators#react-locator), [_vue](https://playwright.dev/docs/other-locators#vue-locator), [data-testid](https://playwright.dev/docs/locators#locate-by-test-id)
17
18
18
19
Most methods in CodeceptJS use locators which can be either a string or an object.
19
20
20
-
If the locator is an object, it should have a single element, with the key signifying the locator type (`id`, `name`, `css`, `xpath`, `link`, `react`, `class`or `shadow`) and the value being the locator itself. This is called a "strict" locator.
21
+
If the locator is an object, it should have a single element, with the key signifying the locator type (`id`, `name`, `css`, `xpath`, `link`, `react`, `class`, `shadow`or `pw`) and the value being the locator itself. This is called a "strict" locator.
The Mozilla team has written an excellent guide titled [Writing reliable locators for Selenium and WebDriver tests](https://blog.mozilla.org/webqa/2013/09/26/writing-reliable-locators-for-selenium-and-webdriver-tests/).
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
102
102
* @prop {object} [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
103
+
* @prop {string} [testIdAttribute=data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
103
104
*/
104
105
constconfig={};
105
106
@@ -379,6 +380,7 @@ class Playwright extends Helper {
379
380
highlightElement: false,
380
381
};
381
382
383
+
process.env.testIdAttribute='data-testid';
382
384
config=Object.assign(defaults,config);
383
385
384
386
if(availableBrowsers.indexOf(config.browser)<0){
@@ -464,6 +466,7 @@ class Playwright extends Helper {
0 commit comments