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.check: Clicking the checkbox did not change its state #20893

Closed
amrsa1 opened this issue Feb 14, 2023 · 10 comments
Closed

[BUG] locator.check: Clicking the checkbox did not change its state #20893

amrsa1 opened this issue Feb 14, 2023 · 10 comments

Comments

@amrsa1
Copy link

amrsa1 commented Feb 14, 2023

Context:

  • Playwright Version: 1.30.0
  • Operating System: mac
  • Node.js version: 18
  • Browser: all

Code Snippet

get elevatorCheckbox() { return this.page.getByText('Elevator') }

Describe the bug

Unable to interact with checkbox due to the following error , i have used many approaches to inreract with this element but but couldn't find any solution

locator.check: Clicking the checkbox did not change its state
    =========================== logs ===========================
    waiting for getByText('Elevator')
      locator resolved to <span class="css-bc9awv" data-component="Text">Elevator</span>
    attempting click action
      waiting for element to be visible, enabled and stable
        forcing action
      element is visible, enabled and stable
      scrolling into view if needed
      done scrolling
      performing click action
      click action done
      waiting for scheduled navigations to finish
      navigations have finished
    ============================================================

       at ../../pages/ValuationPage.ts:114

    > 114 |         await this.elevatorCheckbox.check({force:true});
@amrsa1
Copy link
Author

amrsa1 commented Feb 14, 2023

using his command works fine with me

document.querySelector('#valuationHasElevator-checkbox').click()

@aslushnikov
Copy link
Collaborator

@amrsa1 not much we can do unless there's a good repro that we can run & debug locally. Any chance you can provide one?

@amrsa1
Copy link
Author

amrsa1 commented Feb 14, 2023

So hard to do this, since its an actual project with certain auth
i can provide the following, might be userful

Screenshot 2023-02-14 at 16 09 50

using element id and changing check to be click lead to this error

  locator.click: Element is outside of the viewport
    =========================== logs ===========================
    waiting for locator('input[id="valuationHasElevator-checkbox"]')
      locator resolved to <input tabindex="-1" type="checkbox" class="css-1li7gtf…/>
    attempting click action
      waiting for element to be visible, enabled and stable
        forcing action
      element is visible, enabled and stable
      scrolling into view if needed
      done scrolling
    ===================================================

@aslushnikov
Copy link
Collaborator

aslushnikov commented Feb 14, 2023

@amrsa1 hm, looking at your DOM: does the checkbox actually get checked if you manually click on the "Elevator" text, not on the checkbox?

@amrsa1
Copy link
Author

amrsa1 commented Feb 14, 2023

@aslushnikov yes it works totally fine on UI side, i can click on ticket or the checkbox
but unable to interact with it with playwright for the reasons mentioned above

@aslushnikov
Copy link
Collaborator

@aslushnikov well, no more ideas, and not much we can do here. I'll have to close this then.

But if you'll come up with some kind of repro that we can run locally that reproduces this behavior, then we'll have chances! Feel free to submit a new issue in this case.

@amrsa1
Copy link
Author

amrsa1 commented Feb 15, 2023

@aslushnikov

using the same element but like below

await this.minergieCheckbox.dispatchEvent('click');

it works totally fine, also i have noticed for some reason when i use this.minergieCheckbox.waitFor()
it resolve to be hidden element i dont know why

@mdanilowicz
Copy link

I had the same problem, but only with docker image. "Locally" everything works perfect

Solution provided by @amrsa1 solved this problem. Thanks!

@cpc-anishb
Copy link

@amrsa1 Thank you! your suggestion for dispatching event works always.

@jsampath2552000
Copy link

My checkbox has no name nearby and it is very hard to click, Even dispatching it won't work!!
image
The error : - waiting for locator('xpath=(//input[@Class='ag-input-field-input ag-checkbox-input' and @tabindex='-1'])[13]') to be visible
- locator resolved to hidden <input ref="eInput" tabindex="-1" type="checkbox" id="a…/>

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

5 participants