robotframework / SeleniumLibrary

Web testing library for Robot Framework
Apache License 2.0
1.38k stars 761 forks source link

Incorporate the expected conditions of Selenium #1827

Closed emanlove closed 5 months ago

emanlove commented 1 year ago

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 commented 1 year ago

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

emanlove commented 1 year ago

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

emanlove commented 10 months ago

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

Design

yuriverweij commented 10 months ago

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 commented 5 months ago

Fixed in #1865