From 73f38dc0f3de3296cf5c33b664313180dfa2687b Mon Sep 17 00:00:00 2001 From: KobeN <7845001+kobenguyent@users.noreply.github.com> Date: Tue, 16 Apr 2024 06:35:29 +0200 Subject: [PATCH] fix: data-testid test (#4302) --- lib/locator.js | 2 +- test/helper/Playwright_test.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/locator.js b/lib/locator.js index 9c6efd53f..1cffebb24 100644 --- a/lib/locator.js +++ b/lib/locator.js @@ -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'); } /** diff --git a/test/helper/Playwright_test.js b/test/helper/Playwright_test.js index ce33e210d..05665d807 100644 --- a/test/helper/Playwright_test.js +++ b/test/helper/Playwright_test.js @@ -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); + }); });