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

Feature: Generate way for SitePrism to regenerate #root_element (Fixes Stale Element) #85

Open
luke-hill opened this issue Nov 2, 2020 · 5 comments

Comments

@luke-hill
Copy link
Collaborator

Expected Behavior

When using a section which becomes stale, when trying to access any method or locator inside it, SitePrism should firstly try to regenerate the root_element and then if not, provide some API for doing so, to mitigate un-wanted StaleElements being caused by headers/footers being altered.

Actual Behavior

When using a section which becomes stale, when trying to access any method or locator inside it, a StaleElement is thrown

Steps to reproduce

N/A

@tchiaspko
Copy link

Is there a workaround?

@luke-hill
Copy link
Collaborator Author

Yes there is, but it is cumbersome (Essentially this logic is kind of what will exist when I get around to coding it).

So there is a method on stale capybara elements (You can tell their stale by a debugger inspecting them returning Obsolete::Capybara::Element as it's element.inspect invocation.

When you detect that, you can rerun #reload.

However the bigger issue is that something isn't always stale because it is stale, inside SitePrism. So the bigger issue here is to provide something more robust.

Rest assured it will be fixed. But given there is no active contributions yet into the recently set up OpenCollective account, it's tough to find time to work on this project at the moment.

@luke-hill
Copy link
Collaborator Author

@tchiaspko there is a partial fix available in a subsidiary gem now.

See: https://github.com/site-prism/automation_helpers/blob/main/lib/automation_helpers/extensions/capybara/node/element.rb#L23-L28

This will tell you if the element is stale. We now need to integrate this in and find a way of finding whether a section is stale (or the element), and then re-generating.

@andrewhavens
Copy link

andrewhavens commented Jan 5, 2023

I have had some success by using the allow_reload option.

page.my_sections(allow_reload: true).first.my_elements

Capybara warns that it's a beta feature, so be aware that they might decide to remove it in the future.

@luke-hill
Copy link
Collaborator Author

This is interesting because I spoke to thomas a while ago about this when I was making the #stale? check and he indicated ways to fix it on the testing end. Not at capybara end.

This "might" make this a whole lot easier now... Watch this space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants