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

How to wait for css property to completely updated #944

Open
wenyugu opened this issue Sep 10, 2023 · 5 comments
Open

How to wait for css property to completely updated #944

wenyugu opened this issue Sep 10, 2023 · 5 comments
Labels
question Questions related to rod

Comments

@wenyugu
Copy link

wenyugu commented Sep 10, 2023

Rod Version: v0.114.0

I have some code that clicks on a button and checks whether a specific element on the page changes its css display property to none upon a successful operation eg. if the available date picked is available, then the date entry form would be collapsed and have css property display: none. How do I wait for css property to be completely updated? I don't think race selectors are useful here since the outcome is uncertain and depends on the result of user operations, typically verified by an backend API call.

@wenyugu wenyugu added the question Questions related to rod label Sep 10, 2023
@github-actions
Copy link

Please fix the format of your markdown:

1:22 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]

generated by check-issue

@ysmood
Copy link
Member

ysmood commented Sep 10, 2023

page.MustElement("#my-elem").MustWait(`el => getComputedStyle(el).display == 'none'`)

@wenyugu
Copy link
Author

wenyugu commented Sep 10, 2023

But this is expecting this element to change its display to none; however, this is not always the case. If, for example, the date is unavailable, then it will stay visible. How do I add a timeout to deal with this?

@ysmood
Copy link
Member

ysmood commented Sep 10, 2023

@navi504
Copy link

navi504 commented Sep 12, 2023

err := rod.Try(func() {
  page.Timeout(2 * time.Second).
   MustElement("#my-elem").MustWait(`el => getComputedStyle(el).display == 'none'`)
 })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

3 participants