Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move to Locator playwright #3738

Merged
merged 20 commits into from
Aug 19, 2023
Merged

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?

lib/helper/Playwright.js Outdated Show resolved Hide resolved
lib/helper/Playwright.js Show resolved Hide resolved
@DavertMik
Copy link
Contributor

@kobenguyent @EgorBodnar

Published this PR as [email protected]
Please check this new version

@kobenguyent
Copy link
Collaborator Author

@kobenguyent @EgorBodnar

Published this PR as [email protected]

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

> [email protected] 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
8 checks passed
@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.
6 participants