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

WebdriverJS with the Safari driver causes noSuchWindowException #936

Closed
1 task done
Zidious opened this issue Nov 20, 2023 · 3 comments · Fixed by #1031
Closed
1 task done

WebdriverJS with the Safari driver causes noSuchWindowException #936

Zidious opened this issue Nov 20, 2023 · 3 comments · Fixed by #1031
Assignees
Labels
next up Ticket is groomed for next sprint PRIORITY: moderate Moderate priority item; should be scheduled within a few weeks QA: required This ticket requires QA signoff signOff-QA

Comments

@Zidious
Copy link
Contributor

Zidious commented Nov 20, 2023

Product

webdriverjs

Product Version

4.8.0

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

Print axe results

Actual

Throws an error

How to Reproduce

const { AxeBuilder } = require("@axe-core/webdriverjs");
const { Builder } = require("selenium-webdriver");

(async () => {
  const driver = new Builder().forBrowser("safari").build();
  await driver.get("https://www.google.com");

  const results = await new AxeBuilder(driver).analyze();
  console.log(results);

  await driver.quit();
})();

Additional context

Run into the same issue in Ruby and Java.

We should look to to removing:

try {
await driver.executeScript(`window.open('about:blank')`);
const handlers = await driver.getAllWindowHandles();
await driver.switchTo().window(handlers[handlers.length - 1]);
await driver.get('about:blank');
} catch (error) {
throw new Error(
`switchTo failed. Are you using updated browser drivers? \nDriver reported:\n${error}`
);
}

In favour of something like:

try {
  await driver.switchTo().newWindow('tab')
  await driver.get('about:blank');
} catch (error) {
  throw new Error(
    `switchTo failed. Are you using updated browser drivers? \nDriver reported:\n${error}`
  );
}

Selenium doesn't appear to document the above in their docs, but it's available within their source code

@dequejenn dequejenn added PRIORITY: high High priority item; should be scheduled in this or next sprint next up Ticket is groomed for next sprint labels Nov 30, 2023
@dequejenn dequejenn added PRIORITY: moderate Moderate priority item; should be scheduled within a few weeks and removed PRIORITY: high High priority item; should be scheduled in this or next sprint labels Dec 11, 2023
@dequejenn dequejenn added the QA: required This ticket requires QA signoff label Dec 11, 2023
scottmries added a commit that referenced this issue 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 <[email protected]>
Co-authored-by: michael-siek <[email protected]>
@padmavemulapati
Copy link

padmavemulapati commented Apr 2, 2024

Verified this with the latest RC-build (4.9.1-4cb64b0.0 )
I am seeing below error when executing on safari (working fine on chrome and firefox)

dq_padmavathi@DQPadmavathi-MacBook-Pro axe-core-npm % node tests/wdjs.js               
/Users/dq_padmavathi/Desktop/DevtoolsAutomation/qa-axe-devtools-api-daf/axe-core-npm/node_modules/selenium-webdriver/remote/index.js:256
              let cancelToken = earlyTermination.catch((e) => reject(Error(e.message)))
                                                                     ^

Error: Server terminated early with status 1
    at /Users/dq_padmavathi/Desktop/DevtoolsAutomation/qa-axe-devtools-api-daf/axe-core-npm/node_modules/selenium-webdriver/remote/index.js:256:70
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.11.1

for this axe-core/webdriverjs -version is 4.9.1-4cb64b0.0 selenium-webdriver- version is 4.19.0, which is latest`

Code used

const { AxeBuilder } = require("@axe-core/webdriverjs");
const { Builder } = require("selenium-webdriver");

(async () => {
  const driver = new Builder().forBrowser("safari").build();
  await driver.get("https://www.google.com");

  const results = await new AxeBuilder(driver).analyze();
  console.log(results);

  await driver.quit();
})();

and enabled the 'Allow Remote Automation' option in Safari's Develop menu also to control Safari via WebDriver

Environment:

Label Value
Product axe-core-npm
Version 4.9.1-4cb64b0.0
Selenium-webdriver-Version 4.19.0
OS-Details _MACOS-Sonoma_14.4 and Windows 11 _
BrowserDetails Chrome Version 123.0.6312.87 && Firefox 123.0.1

@Zidious / @michael-siek can you please take a look into this

Note: Tried with Axe-core/webdriverjs@next version - 4.8.6-b72c735.0" and selenium-webdriver-4.17.0` too same error getting

@scottmries
Copy link
Contributor

I'm not able to reproduce this, but I wonder if it's because of the requirement to enable safaridriver.
If it is, how do we disable safaridriver locally to verify manually, and then test?

@padmavemulapati
Copy link

Getting the results when executing on Safari Browser,
Valdiated with the RC-build -4.9.1-4cb64b0.0
Steps validated:

1. create a directory and cd to that
2. npm init -y
3. npm i @axe-core/webdriverjs@rc
4. npm i selenium-webdriver
5. create a test file 'test.js' with contents -
const { AxeBuilder } = require("@axe-core/webdriverjs");
const { Builder } = require("selenium-webdriver");

(async () => {
  const driver = new Builder().forBrowser("safari").build();
  await driver.get("https://www.google.com/");

  const results = await new AxeBuilder(driver).analyze();
  console.log(results);

  await driver.quit();
})();
Execute with - node test.js

Gettting the Results:
image

Result file attaching with .txt. format

result.txt

Environment:

Label Value
Product axe-core-npm
Version 4.9.1-4cb64b0.0
Selenium-webdriver-Version 4.19.0
OS-Details _MACOS-Sonoma_14.4 _
BrowserDetails _Chrome Version 123.0.6312.87 , Safari Version 17.4.1 (19618.1.15.11.14) && Firefox 123.0.1 _

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next up Ticket is groomed for next sprint PRIORITY: moderate Moderate priority item; should be scheduled within a few weeks QA: required This ticket requires QA signoff signOff-QA
Projects
None yet
5 participants