SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

Add keywords for dealing with stale elements

Open Brownies opened this issue 3 years ago • 2 comments

For my use case it would be nice to have some keywords to be able to deal with elements that get removed from the DOM. Something along the lines of

  • Wait Until Element Is Stale
  • Get Element Staleness
  • Element Should (Not) Be Stale

I wrote a rudimentary Python plugin at work using Selenium's staleness_of condition. I got the OK to use the plugin as a base and spend some time so I'd be willing to try and provide a PR as well if this feature makes sense and would be a good fit for the library.

Brownies avatar Jan 13 '22 11:01 Brownies

I know personally I have been hesitant to add an exhaustive set of keywords which specifically wait until some state. I was just now talking with Tatu about a question someone raised about waiting. He showed me this solution

element = WebDriverWait(self.driver, 30, ignored_exceptions=(StaleElementReferenceException,)).until(
                EC.element_to_be_clickable((By.ID, "description"))
            )

I was thinking a generic Wait until Element State Is/Is Not might be the solution. There is an full list of expected conditions that we could take advantage of .. I was just going to put in a reminder ticket for myself and saw your request. Do you think this (with a Get Element State and Element State Should (Not) Be keywords) fulfill your request?

emanlove avatar Jan 19 '22 16:01 emanlove

Yeah that would be great!

Brownies avatar Jan 24 '22 09:01 Brownies