Skip to content

Conversation

@kobenguyent
Copy link
Collaborator

@kobenguyent kobenguyent commented Jul 6, 2023

Motivation/Description of the PR

Applicable helpers:

  • Playwright

Type of change

  • 🐛 Bug fix

Checklist:

  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

Copy link
Contributor

@DavertMik DavertMik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to me
But can we use new clear method?

@DavertMik
Copy link
Contributor

@kobenguyent @EgorBodnar

Published this PR as codeceptjs@3.5.4-beta.1
Please check this new version

@kobenguyent
Copy link
Collaborator Author

@kobenguyent @EgorBodnar

Published this PR as codeceptjs@3.5.4-beta.1

Please check this new version

Thank you @DavertMik 😊

@ngraf
Copy link
Contributor

ngraf commented Aug 8, 2023

I ran my biggest test suite with a lot of different locators and techniques against 3.5.4-beta.1 with Playwright.
I discovered one issue:

🐞 Issue: I.switchTo(locator) step does not fail when locator was not found.
Expected
switchTo does fail when locator does not match any element.
Actual
switchTo does not fail when locator does not match any element.

Proof:
This scenario fails as expected with latest stable version, but is unexpectedly green in tested beta version:

Scenario('Playwright locator Bug with iframe not found', async ({I}) => {
    I.amOnPage('https://www.w3schools.com/html/html_iframe.asp')
    // I.switchTo('iframe[ title = "W3Schools HTML Tutorial']) // This would be the correct locator
    I.switchTo('iframe[ title = "W3Schools HTML Tutorial    -> I ADDED THIS TEXT WITH THE GOAL TO NOT FIND IFRAME. TEST SHOULD FAIL BUT IT DOES NOT WITH CodeceptJS version 3.5.4-beta.1 <-"]')

})

@kobenguyent
Copy link
Collaborator Author

I.amOnPage('https://www.w3schools.com/html/html_iframe.asp')
// I.switchTo('iframe[ title = "W3Schools HTML Tutorial']) // This would be the correct locator
I.switchTo('iframe[ title = "W3Schools HTML Tutorial -> I ADDED THIS TEXT WITH THE GOAL TO NOT FIND IFRAME. TEST SHOULD FAIL BUT IT DOES NOT WITH CodeceptJS version 3.5.4-beta.1 <-"]')

Hi @ngraf I tried your scenario against 3.x and nothing fails, so I think it's not the issue from this Locator changes.

    it.only('should switch reference to iframe content', () => {
      I.amOnPage('https://www.w3schools.com/html/html_iframe.asp');
      // I.switchTo('iframe[ title = "W3Schools HTML Tutorial']) // This would be the correct locator
      I.switchTo('iframe[ title = "W3Schools HTML Tutorial    -> I ADDED THIS TEXT WITH THE GOAL TO NOT FIND IFRAME. TEST SHOULD FAIL BUT IT DOES NOT WITH CodeceptJS version 3.5.4-beta.1 <-"]')

    });
➜  CodeceptJS git:(3.x) ✗ npm run test:unit:webbapi:playwright

> codeceptjs@3.5.3 test:unit:webbapi:playwright
> mocha test/helper/Playwright_test.js



  Playwright
    #switchTo
      ✔ should switch reference to iframe content


  1 passing (825ms)

➜  CodeceptJS git:(3.x) ✗ 

@ngraf
Copy link
Contributor

ngraf commented Aug 16, 2023

Ok, I guess you are right and the issue is not caused by this feature branch then.

@DavertMik DavertMik merged commit 6cd32fb into 3.x Aug 19, 2023
@kobenguyent kobenguyent deleted the feat/move-to-locator-playwright branch August 28, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST](playwright) migrate locators from ElementHandle to Locator.

7 participants