[py] support for custom error messages through functions for `WebDriverWait.until/until_not`
User description
🔗 Related Issues
Implements https://github.com/SeleniumHQ/selenium/issues/14552
💥 What does this PR do?
Allow specifying a callable for the message argument in WebDriverWait.until / until_not
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
- New feature (non-breaking change which adds functionality and tests!)
PR Type
Enhancement, Tests
Description
-
Allow callable as
messageinWebDriverWait.until/until_not -
Update method signatures and error handling for callables
-
Add tests for callable and string timeout messages
Changes walkthrough 📝
| Relevant files | |||
|---|---|---|---|
| Enhancement |
| ||
| Tests |
|
Need help?
Type /help how to ...in the comments thread for any questions about Qodo Merge usage.Check out the documentation for more information.
PR Reviewer Guide 🔍
(Review updated until commit https://github.com/SeleniumHQ/selenium/commit/147913aef0c5686ad14df6fc8d53f44f5260a276)
Here are some key observations to aid the review process:
|
🎫 Ticket compliance analysis ✅ 14552 - PR Code Verified Compliant requirements: • Allow specifying a callable for the message argument in WebDriverWait.until / until_not • Enable constructing error messages using the driver when an error occurs • Make code more readable by avoiding try-catch structures Requires further human verification: • Support the usage example: WebDriverWait(driver, 10).until(lambda x: x.find_element(By.ID, "someId"), lambda x: f'Message: {x.current_url}') - The implementation accepts callables but the test doesn't verify this exact usage pattern with driver as parameter |
| ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
| 🧪 PR contains tests |
| 🔒 No security concerns identified |
⚡ Recommended focus areas for reviewCallable Parameter
|
Thank you, @Delta456 for this code suggestion.
The support packages contain example code that many users find helpful, but they do not necessarily represent the best practices for using Selenium, and the Selenium team is not currently merging changes to them.
We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. If you have any questions, please contact us
PR Code Suggestions ✨
Latest suggestions up to 147913a Explore these optional code suggestions:
| Category | Suggestion | Impact |
| Possible issue |
Pass exception to callableThe current implementation calls the callable py/selenium/webdriver/support/wait.py [150]
Suggestion importance[1-10]: 9__ Why: The suggestion correctly identifies a mismatch between the type hint and implementation. The type hint | High |
| ||
Previous suggestions
✅ Suggestions up to commit 147913a
| Category | Suggestion | Impact |
| Possible issue |
Pass exception to callable messageThe current implementation calls the callable py/selenium/webdriver/support/wait.py [150]
Suggestion importance[1-10]: 9__ Why: The suggestion correctly identifies that the callable | High |
| General |
✅
| Low |
I was watching it again just now and I was wondering... It hasn't been well thought out yet, but if the message function causes an error, will the original WebDriver error be lost? If so, has there been any consideration as to whether this specification is acceptable?
I was watching it again just now and I was wondering... It hasn't been well thought out yet, but if the message function causes an error, will the original WebDriver error be lost? If so, has there been any consideration as to whether this specification is acceptable?
I believe it should be acceptable as long you know that you are providing a custom error message. IF you don't want the new error message, you can always leave that parameter.
I thought we were no longer maintaining these support packages?
That's true. We want to avoid making changes here and empower users to do their own.