Skip to content

Unable to move cursor when multiple elements exist: locator.boundingBox: Error: strict mode violation #3879

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

Closed
mirao opened this issue Sep 21, 2023 · 0 comments · Fixed by #3883

Comments

@mirao
Copy link
Contributor

mirao commented Sep 21, 2023

It's a regression in 3.5.4 (also 3.5.5 is affected). CC: @kobenguyent

What are you trying to achieve?

The test should pass (a first found element should be used).
This is how it behaves in 3.5.3

  Test
    I am on page "https://codecept.io/"
    I move cursor to {xpath: .//div[@class = 'content']}
  ✔ OK in 2174ms

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

-- FAILURES:

  1) My
       Test:
     locator.boundingBox: Error: strict mode violation: locator('xpath=.//div[@class = \'content\']') resolved to 3 elements:
    1) <div class="content" data-v-e3b729f8="">…</div> aka getByText('CodeceptJS is opensource MIT licensed testing framework. Works with your favorit')
    2) <div class="content" data-v-e3b729f8="">…</div> aka locator('#app div').filter({ hasText: 'Scenario Driven Write acceptance tests from user\'s perspective. Make tests reada' }).nth(1)
    3) <div class="content" data-v-e3b729f8=""></div> aka locator('div').filter({ hasText: '# Realworld Example Can we use it for long scenarios? Sure! const { faker } = re' }).nth(2)

=========================== logs ===========================
waiting for locator('xpath=.//div[@class = \'content\']')
============================================================
  locator.boundingBox: Error: strict mode violation: locator('xpath=.//div[@class = \'content\']') resolved to 3 elements:
      1) <div class="content" data-v-e3b729f8="">…</div> aka getByText('CodeceptJS is opensource MIT licensed testing framework. Works with your favorit')
      2) <div class="content" data-v-e3b729f8="">…</div> aka locator('#app div').filter({ hasText: 'Scenario Driven Write acceptance tests from user\'s perspective. Make tests reada' }).nth(1)
  
  Scenario Steps:
  - I.moveCursorTo({xpath: .//div[@class = 'content']}) at Test.<anonymous> (./My_test.ts:7:7)
  - I.amOnPage("https://codecept.io/") at Test.<anonymous> (./My_test.ts:6:7)

Provide test source code if related

Feature("My");

const { I } = inject();

Scenario("Test", () => {
    I.amOnPage("https://codecept.io/");
    I.moveCursorTo(locate("div").withAttr({ class: "content" }));
});

Details

  • CodeceptJS version: 3.5.4, 3.5.5
  • NodeJS Version: 18.15
  • Operating System: Ubuntu 22.04
  • Playwright 1.37.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant