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

StalenessOf returns true for live element! #3876

Closed
DynConcepts opened this issue Apr 21, 2017 · 9 comments
Closed

StalenessOf returns true for live element! #3876

DynConcepts opened this issue Apr 21, 2017 · 9 comments
Labels

Comments

@DynConcepts
Copy link

The following ALWAYS returns true for the input tag....

stale

Accessing the Parent via "/.." returns false.....

@DynConcepts
Copy link
Author

Just pulled and searched the source... Confirmed this behavior... I believe this to be a BUG...

   public static Func<IWebDriver, bool> StalenessOf(IWebElement element)
    {
        return (driver) =>
        {
            try
            {
                // Calling any method forces a staleness check
                return element == null || !element.Enabled;
            }
            catch (StaleElementReferenceException)
            {
                return true;
            }
        };
    }

@jimevans
Copy link
Member

Yes, the code would fail in that instance. It's one reason that use of the ExpectedConditions class is heavily discouraged in .NET, and one reason that the maintainer has expressed a huge regret at having ever implemented it in the first place.

@DynConcepts
Copy link
Author

Jim, Just an observation... It took over 20 man hours (at over $200/hr) to isolate this....and that is just one teams experience. It is a trivial change to make it work...so why not simply fix it???

@ddavison
Copy link
Member

If it's a trivial change, try your hand at a Pull Request @DynConcepts 👍 help us make the project better

@DynConcepts
Copy link
Author

ddavison - alas there are some constraints at play... The fix is...

  try
        {
            // Calling any method forces a staleness check
            bool enabled = rawElement.Enabled;
            return false;
        }

@jimevans
Copy link
Member

@DynConcepts Did I say I wouldn't be fixing it? I don't think I said that. In point of fact, I'm traveling today, and don't know if I will get around to it before at least next week. I'm sorry if my inability to be sitting at a working development environment to jump on fixing your particular issue within 10 minutes of having added a comment to it in the tracker does not meet your idea of a Service Level Agreement for a piece of software I volunteer my time and effort to, and you paid no money to use.

Frankly, it's not a high priority for me, because a dedicated ExpectedConditions class an ill-conceived concept for the .NET bindings. It was coded and implemented when slavishly offering a .NET analogue of every single piece of code offered by the Java language bindings was thought to be a good idea.

@DynConcepts
Copy link
Author

Jim, That was not my intention at all, and you have my deepest apologies if it came across that in any way shape or form.

Out of curiosity, if that is the state of the class, why not deprecate it? [ObsoleteAttribute]....

I too spend a large amount of volunteer time, so I know exactly where you are coming from.

@jimevans
Copy link
Member

It hasn't been marked with the attribute because, frankly, very few people actually use it. Most .NET developers opt to just use a lambda function directly when using WebDriverWait. Now that there is a proven case of an issue with these methods, I would expect a deprecation and removal before too long.

@barancev
Copy link
Member

Closing in favour of DotNetSeleniumTools/DotNetSeleniumExtras#9

@lock lock bot locked and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants