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

What are the default durations for the WebDriver::Query timeout and polling / What is a reasonable polling time #66

Closed
bcpeinhardt opened this issue Sep 5, 2021 · 3 comments

Comments

@bcpeinhardt
Copy link
Contributor

What are the default durations for the WebDriver::Query timeout and polling? I'm working with a website with slow load times and I'd like to increase the explicit wait timeout. I know I can set this with .wait() on the query but I'm not sure what a reasonable default for the poll time is, as I've never had a need to manually set it before.

@stevepryde
Copy link
Collaborator

stevepryde commented Sep 5, 2021

The default timeout is 20 seconds and the default interval is 0.5 seconds. These should be reasonable but you can create and set a different default poller by using the WebDriver::set_query_poller() method.

The reason this is better than using implicit waits is because your code now has the option to not wait if you just want to check whether something exists without blocking.

When trying to decide on a reasonable default timeout, consider how long you would normally need to wait for a page to load or an element to show up before you would consider it a bug. This is obviously in the context of testing websites. If you're just automating a website you may have different considerations.

@bcpeinhardt
Copy link
Contributor Author

Thanks! Yup I'm actually automating a site for use (its an order management system where we process orders) not testing so generally the consideration for an element that's supposed to be there is how long until I'm pretty damn sure there has been an error. For an element that may or may not be there where I need to make a decision based on whether or not it is present, I try to explicit wait on some indicator element that is always there (like a div container the element is in etc) that will let me know the element would be loaded if it were supposed to be, then do a nowait query on the element I'm looking for, otherwise the explicit waits will build up fast. As I'm adding functionality I'm moving away from page objects and toward component objects now so this will likely get built into those. I had to build the MVP in JavaScript with the npm selenium-webdriver but now I'm porting to Rust and pretty pumped to see how much I can clean up this code with your query api, and also just to be in rust again in general.

@stevepryde
Copy link
Collaborator

stevepryde commented Sep 6, 2021

Also note that if the element is found then it will return immediately. The wait / timeout only applies in the case where the element query couldn't find the element.

Have a look through the query interface for more details.

Also if you have an existing element already and want to wait for it to either change an attribute or disappear you can use the element.wait_until() features for that.

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