Skip to content

fix: WebdriverJS with Safari can cause noSuchWindowException#1027

Closed
scottmries wants to merge 1 commit intodevelopfrom
sr-936-new-window-exception
Closed

fix: WebdriverJS with Safari can cause noSuchWindowException#1027
scottmries wants to merge 1 commit intodevelopfrom
sr-936-new-window-exception

Conversation

@scottmries
Copy link
Copy Markdown
Contributor

Reproing according to the associated issue would occasionally throw a noSuchWindowException, about one in three times; this change should fix that.

Closes: #936

@scottmries scottmries self-assigned this Mar 22, 2024
@scottmries scottmries requested a review from a team as a code owner March 22, 2024 15:05
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 22, 2024

CLA assistant check
All committers have signed the CLA.

@scottmries scottmries removed their assignment Mar 22, 2024
@scottmries scottmries force-pushed the sr-936-new-window-exception branch from 15bd58b to 21c454e Compare March 22, 2024 16:49
Copy link
Copy Markdown
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd want to scope this fix to webdriverjs so it'd only appear in that package changelog i.e. fix(webdriverjs): ...

Left a comment inline

await driver.executeScript(`window.open('about:blank')`);
const handlers = await driver.getAllWindowHandles();
await driver.switchTo().window(handlers[handlers.length - 1]);
await driver.switchTo().newWindow('tab');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Scott - this was my mistake I forgot to amend the issue description. There was some discussion offline about switching to using newWindow. Found that it was only added in Selenium 4 and we do want to continue supporting Selenium 3.

We applied the backwards compatible fix that would work in Selenium 3 and 4 in axe-core-maven-html. For Node it'll be similar

@scottmries scottmries marked this pull request as draft March 28, 2024 16:54
scottmries added a commit that referenced this pull request Apr 1, 2024
This is the workaround fix that supports Selenium 3 and 4. We would
likely switch to #1027 should we drop Selenium 3 support.
Rather than always using the last handle after opening a new window, we
filter for the unique new handle and use it. This is analogous to the
[axe-core-maven-html
approach](https://github.com/dequelabs/axe-core-maven-html/blob/ad58b26a8d0e2f1afed33b2c5cbca22b54644b99/selenium/src/main/java/com/deque/html/axecore/extensions/WebDriverExtensions.java#L126).

Closes: #936

---------

Co-authored-by: Zidious <Zidious@users.noreply.github.com>
Co-authored-by: michael-siek <me@michaelsiek.com>
@github-actions github-actions Bot mentioned this pull request Apr 1, 2024
@scottmries scottmries closed this Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebdriverJS with the Safari driver causes noSuchWindowException

3 participants