Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

[Dev] - Replace self.wait_for_element_by_css_selector with selenium's methods #288

Open
chriddyp opened this issue Aug 28, 2018 · 1 comment

Comments

@chriddyp
Copy link
Member

I wrote some testing utils on top of selenium to do things like "wait for an element to appear". they're kind of hacky and sometimes they seem unreliable. So, sometimes we end up putting time.sleep in our tests instead of some proper wait for statement.

Turns out that selenium has its own "wait for" methods. We should replace our utils with these new methods and start using these methods in our new tests.

Here is an example of the official selenium "wait" API:
https://github.com/plotly/dash-component-boilerplate/blob/1d2ee1d9fc1b6fa834fda3dc38064297f8154085/tests/test_render.py#L4-L23

cc @plotly/dash

@rmarren1
Copy link
Contributor

I've used these before with a Dash app, they're great.

Some things I learned:

  • These are the best docs for expected conditions

  • element_to_be_clickable is the most useful wait for elements you want to interact with after they appear.

  • The dash loading state covers the entire screen when a callback is requested, and there is a bit of lag time between when the DOM updates and when the loading state disappears. This makes it difficult to wait for and then click on things in succession since the loading state will steal the clicks after the wait is released, a time.sleep is still useful here, haven't tried anything more complicated than that.

  • Action chains are important for more complex interactions (e.g. opening a dropdown then clicking a sub-element of the dropdown), just clicking both in succession might not work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants