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

Incorporate the expected conditions of Selenium #1827

Closed
emanlove opened this issue May 18, 2023 · 5 comments
Closed

Incorporate the expected conditions of Selenium #1827

emanlove opened this issue May 18, 2023 · 5 comments
Assignees
Labels
acknowledge To be acknowledged in release notes enhancement priority: high rc 2
Milestone

Comments

@emanlove
Copy link
Member

There is now a a variety of conditions that Selenium can either wait for, get, or check against. The idea is that we can create a small set of generic keywords, maybe

Wait Until Element State Is (Not)
Get Element State
Element States Should (Not) Be

which allows for one to wait for, get, or check against the element state. There is also capability to create a custom condition within selenium that could be incorporated into the library and these keywords. As for names maybe condition or expected condition might be better as not all object to be checked I suspect would be an element.

Although not part of this issue, it may be worth starting to have a conversation around whether or not these keywords might allow for reducing the number of library keywords and deprecating the "Wait For ..." keywords.

Related Issues:

Add new selenium 4 timeout getters #1825
Add keywords for dealing with stale elements #1767
Add "Wait for DOM inactivity" keyword which waits until page is fully loaded/rendered #1764
New Keyword 'Element Attriubte Should Contain' #1129
New Keyword 'Wait Until Element Contains attribute' #1126
How we can deal with stale element reference with selenium libray?We need a keyword to deal with stale element reference #1792
Add "Wait for DOM inactivity" keyword which waits until page is fully loaded/rendered #1764
Wait For Condition and Title Should Be seem to be out of sync #1728
Provide support for waiting for a value in a textarea element #1726
Add parameter to make Wait Until Page Contains case insensitive #1517
Wait until does not contain element always waits for full amount of wait time #1364

References:

selenium.webdriver.support.expected_conditions within API
Example implementation

@emanlove
Copy link
Member Author

Some of my initial notes on (what I was originally calling) Wait For Condition

  • Can we allow the user to use the same name (ie element_to_be_clickable ,text_to_be_present_in_element, etc) so that the conditions aren't hard coded within the library? so that as the conditions change with selenium we don't need to change the code in the library? How do we then allow for arguments and type check them? or provide type hints?
  • How do we check for the positive or the negative? is it just a true false check? Can there be just a single negative keyword and what do we call it - Wait till Condition Not ?
  • How do we allow for custom condition? Can the custom condition have the same name as another? if so how do we give precedence or warn that there are more than one with that name?
  • How do we open up these waits and conditions to the library API for usage throughout or within plug-ins?

@emanlove
Copy link
Member Author

emanlove commented Jun 9, 2023

Some more notes from conversation with Lisa Crispin (@lisacrispin)

  • Is there a way to have "and", "or" type conjunctions/logic with the conditions?
  • "Make it positive" - Lisa has a great point about making one's statements in the positive and avoiding double negatives.

@emanlove
Copy link
Member Author

emanlove commented Nov 10, 2023

Making a list of task to be done to complete this work .. (this is a work in progress and subject to change)

Design

  • Categorize conditions (would be nice if shared back to selenium API doc)
  • Sketch out test cases
  • Sketch out keyword usage (in particular ALL, ANY, XOR)
  • Sketch out mapping conditions to keywords
  • Sketch out error message and debug/trace level debugging
  • Review duplicate/related issues within GitHub

Development

  • Create Dynamic Test Page
  • Create Static Test Page
  • Create 'Wait Until Element State Is (Not)' keyword
  • Create 'Get Element State' keyword
  • Create 'Element States Should (Not) Be' keyword
  • Review duplicate/related issues within GitHub

Document & Cleanup

  • Document keyword usage
  • Document to be done (custom conditions)

@yuriverweij
Copy link
Member

yuriverweij commented Nov 14, 2023

I added this comment to the #1865 PR, but add them here as well for possible discussion:

some brainstorming:
wait_for_expected_condition should take the following arguments:

condition (condition=)
timeout (timeout=)
msg (msg=custom message)
arguments (arguments for the condition, depending on the condition this can be a String, WebElement, List)
One (to me) "strange" expectedcondition is "new_window_is_opened". Does this one implicitly add the current number of windows?

Example use of keyword:
${result} Wait for Expected Condition timeout=50ms condition=title_is msg=title did not change title

@emanlove emanlove modified the milestones: v6.2.0, v6.3.0 Nov 19, 2023
@emanlove emanlove added enhancement rc 2 priority: high acknowledge To be acknowledged in release notes labels Apr 16, 2024
@emanlove
Copy link
Member Author

Fixed in #1865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledge To be acknowledged in release notes enhancement priority: high rc 2
Projects
None yet
Development

No branches or pull requests

2 participants