Skip to content

Commit 73f38dc

Browse files
authored
fix: data-testid test (#4302)
1 parent 536c1bc commit 73f38dc

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/locator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ function removePrefix(xpath) {
541541
* @returns {boolean}
542542
*/
543543
function isPlaywrightLocator(locator) {
544-
return locator.includes('_react') || locator.includes('_vue') || locator.includes('data-testid');
544+
return locator.includes('_react') || locator.includes('_vue');
545545
}
546546

547547
/**

test/helper/Playwright_test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,11 +1497,19 @@ describe('using data-testid attribute', () => {
14971497
return I._after();
14981498
});
14991499

1500-
it('should find element by data-testid attribute', async () => {
1500+
it('should find element by pw locator', async () => {
15011501
await I.amOnPage('/');
15021502

15031503
const webElements = await I.grabWebElements({ pw: '[data-testid="welcome"]' });
15041504
assert.equal(webElements[0]._selector, '[data-testid="welcome"] >> nth=0');
15051505
assert.equal(webElements.length, 1);
15061506
});
1507+
1508+
it('should find element by h1[data-testid="welcome"]', async () => {
1509+
await I.amOnPage('/');
1510+
1511+
const webElements = await I.grabWebElements('h1[data-testid="welcome"]');
1512+
assert.equal(webElements[0]._selector, 'h1[data-testid="welcome"] >> nth=0');
1513+
assert.equal(webElements.length, 1);
1514+
});
15071515
});

0 commit comments

Comments
 (0)