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

[Bug]: locator.toString() outputs the same locator twice #30281

Closed
qk5 opened this issue Apr 7, 2024 · 2 comments
Closed

[Bug]: locator.toString() outputs the same locator twice #30281

qk5 opened this issue Apr 7, 2024 · 2 comments

Comments

@qk5
Copy link

qk5 commented Apr 7, 2024

Version

1.43.0

Steps to reproduce

What I am trying to do is:
I have 2 saveButton locators on same page, they both have same name, one in iframe, the other is not.

I need to do something different for each locator, and here is my code snippet for this task:

if ( saveButton.toString().includes('frameLocator') ) {
// do something
}
else {
// do something else
}

Here is my saveButton in iframe, and when I tried to print this in string format, result was displayed 2 times.

let saveButton= page.frameLocator('iframe').getByRole('button', { name: 'Save', exact: true });
console.log(saveButton.toString());

Expected behavior

Expected locator to be printed once:

frameLocator('iframe').getByRole('button', { name: 'Save', exact: true })

Actual behavior

Expected locator was printed twice:

frameLocator('iframe').getByRole('button', { name: 'Save', exact: true })
frameLocator('iframe').getByRole('button', { name: 'Save', exact: true })

Additional context

No response

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 12.59 GB / 31.69 GB
  Binaries:
    Node: 18.18.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.4.0 - C:\demo\node_modules\.bin\npm.CMD
  npmPackages:
    @playwright/test: ^1.43.0 => 1.43.0
@mxschmitt
Copy link
Member

I tried to reproduce but was not able to, maybe you have the console.log twice? Could you maybe share your playwright.config.ts?

it('repro, async ({ page }) => {
  const saveButton = page.frameLocator('iframe').getByRole('button', { name: 'Save', exact: true });
  console.log(saveButton.toString());
});

@qk5
Copy link
Author

qk5 commented Apr 8, 2024

Thanks for looking, I restarted Visual Studio Code this morning, and I can no longer reproduce this bug.
Apologize for the trouble, and I will close this ticket.

@qk5 qk5 closed this as completed Apr 8, 2024
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

No branches or pull requests

2 participants