selenium
selenium copied to clipboard
[dotnet] Safer Displayed method return value evaluation
solution for #10757
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.
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.
@ParanoikCZE are you interested in continuing to work on this one?
@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.
Ok, I'll close this and we can continue to track the issue on #10757 Thank you,