selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[dotnet] Safer Displayed method return value evaluation

Open ParanoikCZE opened this issue 2 years ago • 3 comments

solution for #10757

ParanoikCZE avatar Jun 13 '22 09:06 ParanoikCZE

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 13 '22 09:06 CLAassistant

Any response that isn't a boolean is an error. What if we throw a JavaScript error if the result isn't boolean? Then you can add the JavaScriptError to your list of ignored exceptions in your Wait class.

That's for sure another good solution as it could rethrow the actual message so we would know what really happened. So, what now? Can you do it or should I?

Anyway, meanwhile, I've got another similar issue at WebElement:127 (Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]' to type 'System.Boolean') so all bool properties should be handled. And another issue with probably the same root cause at WebElementFactory.GetElementId:82 (elementDictionary (Parameter 'The specified dictionary does not contain an element reference')).

The root cause in these cases is probably some infrastructure/network issues, as I've started to get many weird performance issues from the whole testing framework.

ParanoikCZE avatar Jun 23 '22 08:06 ParanoikCZE

Sorry for not following up on this. That's interesting that you're seeing it in multiple places. Displayed() kind of makes sense because it is a JS execution, I'm not sure why the driver would be returning the wrong value type from IsElementSelected.

If you can, yes, please update the PR. The JavaScriptError makes sense for Displayed, but not for others, maybe we use the UnknownError for those? Bottom line is we want better error messages so it is easier to see what the actual problem is.

titusfortner avatar Sep 13 '22 01:09 titusfortner

@ParanoikCZE are you interested in continuing to work on this one?

titusfortner avatar Apr 18 '23 14:04 titusfortner

@ParanoikCZE are you interested in continuing to work on this one?

Feel free to handle this, I'm actually out of the free time to focus on this properly to handle all methods.

ParanoikCZE avatar Apr 18 '23 14:04 ParanoikCZE

Ok, I'll close this and we can continue to track the issue on #10757 Thank you,

titusfortner avatar Apr 18 '23 15:04 titusfortner