From bb305bf220ea90aa171ebd9919e8629a02287a5c Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 15 Apr 2024 16:54:46 +0200 Subject: [PATCH] fix: data-testid test --- 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); + }); });