Skip to content

Commit

Permalink
fix: data-testid test (#4302)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Apr 16, 2024
1 parent 536c1bc commit 73f38dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/locator.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function removePrefix(xpath) {
* @returns {boolean}
*/
function isPlaywrightLocator(locator) {
return locator.includes('_react') || locator.includes('_vue') || locator.includes('data-testid');
return locator.includes('_react') || locator.includes('_vue');
}

/**
Expand Down
10 changes: 9 additions & 1 deletion test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1497,11 +1497,19 @@ describe('using data-testid attribute', () => {
return I._after();
});

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

const webElements = await I.grabWebElements({ pw: '[data-testid="welcome"]' });
assert.equal(webElements[0]._selector, '[data-testid="welcome"] >> nth=0');
assert.equal(webElements.length, 1);
});

it('should find element by h1[data-testid="welcome"]', async () => {
await I.amOnPage('/');

const webElements = await I.grabWebElements('h1[data-testid="welcome"]');
assert.equal(webElements[0]._selector, 'h1[data-testid="welcome"] >> nth=0');
assert.equal(webElements.length, 1);
});
});

0 comments on commit 73f38dc

Please sign in to comment.