From 566624f5b555a8424f45e79a4ca0a86e47925d72 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Sat, 2 Sep 2023 08:43:15 +0200 Subject: [PATCH 1/4] fix: switchTo throws error when passing css locator --- lib/helper/Playwright.js | 7 ++++--- test/data/app/view/iframe.php | 4 ++-- test/helper/webapi.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index b1c8d032e..9c825817a 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -2554,11 +2554,12 @@ class Playwright extends Helper { // assertElementExists(els, locator); // get content of the first iframe - if ((locator.frame && locator.frame === 'iframe') || locator.toLowerCase() === 'iframe') { + locator = new Locator(locator, 'css'); + if ((locator.frame && locator.frame === 'iframe') || locator.value.toLowerCase() === 'iframe') { contentFrame = await this.page.frames()[1]; // get content of the iframe using its name - } else if (locator.toLowerCase().includes('name=')) { - const frameName = locator.split('=')[1].replace(/"/g, '').replaceAll(/]/g, ''); + } else if (locator.value.toLowerCase().includes('name=')) { + const frameName = locator.value.split('=')[1].replace(/"/g, '').replaceAll(/]/g, ''); contentFrame = await this.page.frame(frameName); } diff --git a/test/data/app/view/iframe.php b/test/data/app/view/iframe.php index 2004c6035..1c2361558 100755 --- a/test/data/app/view/iframe.php +++ b/test/data/app/view/iframe.php @@ -7,7 +7,7 @@

Iframe test

-