-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: gracefully handle unloaded iframes #133
base: develop
Are you sure you want to change the base?
Conversation
2273530
to
78dbaec
Compare
try | ||
{ | ||
string partialRes = (string)_webDriver.ExecuteAsyncScript(EmbeddedResourceProvider.ReadEmbeddedFile("runPartial.js"), context, options); | ||
// Important to deserialize because we want to reserialize as an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this comment be preserved?
packages/selenium/src/AxeBuilder.cs
Outdated
|
||
|
||
// Don't go any deeper if we are just doing top-level iframe | ||
if (runOptions.Iframes != false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the return early approach this had before
packages/selenium/src/AxeBuilder.cs
Outdated
{ | ||
// get the proper selector the frame and switch to it | ||
var selector = _webDriver.ExecuteScript(EmbeddedResourceProvider.ReadEmbeddedFile("shadowSelect.js"), JsonConvert.SerializeObject(context.Selector, AxeJsonSerializerSettings.Default)); | ||
_webDriver.SwitchTo().Frame(selector as IWebElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally the switchTo
of an unloaded iframe is the thing that puts selenium into a bad state, which means trying to switch back to the parent iframe doesn't work. This is the point where the code is needed to switch to the main window then down into the nested frames again.
Since that is not happening and this catches the error and does not rethrow it for the nested call to RunPartialRecursive
, does that mean that selenium can handle unloaded iframes without erroring without all this code change?
frameStack | ||
)); | ||
} | ||
catch (WebDriverTimeoutException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This catch will probably never be hit as you've added try/catches around almost all other other bits of this code that don't rethrow the error.
foreach (var frameSelector in frameStack) | ||
{ | ||
var selector = _webDriver.ExecuteScript(EmbeddedResourceProvider.ReadEmbeddedFile("shadowSelect.js"), JsonConvert.SerializeObject(frameSelector, AxeJsonSerializerSettings.Default)); | ||
if (selector is IWebElement el) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this if statement is false? You never switch to the frame so the next frameSelector
is not valid for the next frame. Do we expect this to ever be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See comment above)
Closes Issue: #88