@axe-core/webdriverjs 4.7.2 → 4.7.3-alpha.398
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -26
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -13
- package/dist/index.mjs +18 -13
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,21 +10,9 @@ Install [Node.js](https://docs.npmjs.com/getting-started/installing-node) if you
|
|
|
10
10
|
|
|
11
11
|
> Download and install any necessary browser drivers on your machine's PATH. [More on Webdriver setup](https://www.selenium.dev/documentation/en/webdriver/).
|
|
12
12
|
|
|
13
|
-
Install Selenium Webdriver: `npm install selenium-webdriver
|
|
13
|
+
Install Selenium Webdriver: `npm install selenium-webdriver`
|
|
14
14
|
|
|
15
|
-
Install @axe-core/webdriverjs
|
|
16
|
-
|
|
17
|
-
NPM:
|
|
18
|
-
|
|
19
|
-
```console
|
|
20
|
-
npm install @axe-core/webdriverjs
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Yarn:
|
|
24
|
-
|
|
25
|
-
```console
|
|
26
|
-
yarn add @axe-core/webdriverjs
|
|
27
|
-
```
|
|
15
|
+
Install @axe-core/webdriverjs: `npm install @axe-core/webdriverjs`
|
|
28
16
|
|
|
29
17
|
## Usage
|
|
30
18
|
|
|
@@ -33,19 +21,26 @@ This module uses a chainable API to assist in injecting, configuring, and analyz
|
|
|
33
21
|
Here is an example of a script that will drive WebdriverJS to a page, perform an analysis, and then log results to the console.
|
|
34
22
|
|
|
35
23
|
```js
|
|
36
|
-
const AxeBuilder = require('@axe-core/webdriverjs');
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
driver
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
const { AxeBuilder } = require('@axe-core/webdriverjs');
|
|
25
|
+
const { Builder } = require('selenium-webdriver');
|
|
26
|
+
const chrome = require('selenium-webdriver/chrome');
|
|
27
|
+
|
|
28
|
+
(async () => {
|
|
29
|
+
const driver = Builder()
|
|
30
|
+
.forBrowser('chrome')
|
|
31
|
+
.setChromeOptions(new chrome.Options().headless())
|
|
32
|
+
.build();
|
|
33
|
+
await driver.get('https://dequeuniversity.com/demo/mars/');
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const results = await new AxeBuilder(driver).analyze();
|
|
46
37
|
console.log(results);
|
|
47
|
-
})
|
|
48
|
-
|
|
38
|
+
} catch(e) {
|
|
39
|
+
// do something with the error
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
await driver.quit();
|
|
43
|
+
})();
|
|
49
44
|
```
|
|
50
45
|
|
|
51
46
|
## AxeBuilder(driver: Webdriver.WebDriver[, axeSource: string])
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
|
|
33
|
+
AxeBuilder: () => AxeBuilder,
|
|
34
|
+
default: () => AxeBuilder
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(src_exports);
|
|
36
37
|
var import_axe_core2 = __toESM(require("axe-core"));
|
|
@@ -431,7 +432,14 @@ var AxeBuilder = class {
|
|
|
431
432
|
if (runPartialSupported !== true || this.legacyMode) {
|
|
432
433
|
return this.runLegacy(context);
|
|
433
434
|
}
|
|
434
|
-
const
|
|
435
|
+
const { pageLoad } = await this.driver.manage().getTimeouts();
|
|
436
|
+
this.driver.manage().setTimeouts({ pageLoad: 1e3 });
|
|
437
|
+
let partials;
|
|
438
|
+
try {
|
|
439
|
+
partials = await this.runPartialRecursive(context);
|
|
440
|
+
} finally {
|
|
441
|
+
this.driver.manage().setTimeouts({ pageLoad });
|
|
442
|
+
}
|
|
435
443
|
try {
|
|
436
444
|
return await this.finishRun(partials);
|
|
437
445
|
} catch (error2) {
|
|
@@ -465,8 +473,8 @@ var AxeBuilder = class {
|
|
|
465
473
|
/**
|
|
466
474
|
* Get partial results from the current context and its child frames
|
|
467
475
|
*/
|
|
468
|
-
async runPartialRecursive(context,
|
|
469
|
-
if (
|
|
476
|
+
async runPartialRecursive(context, frameStack = []) {
|
|
477
|
+
if (frameStack.length) {
|
|
470
478
|
await axeSourceInject(this.driver, this.axeSource, this.config);
|
|
471
479
|
}
|
|
472
480
|
const frameContexts = await axeGetFrameContext(this.driver, context);
|
|
@@ -474,16 +482,16 @@ var AxeBuilder = class {
|
|
|
474
482
|
await axeRunPartial(this.driver, context, this.option)
|
|
475
483
|
];
|
|
476
484
|
for (const { frameContext, frameSelector, frame } of frameContexts) {
|
|
477
|
-
let switchedFrame = false;
|
|
478
485
|
try {
|
|
479
486
|
(0, import_assert.default)(frame, `Expect frame of "${frameSelector}" to be defined`);
|
|
480
487
|
await this.driver.switchTo().frame(frame);
|
|
481
|
-
|
|
482
|
-
partials.push(...await this.runPartialRecursive(frameContext));
|
|
488
|
+
partials.push(...await this.runPartialRecursive(frameContext, [...frameStack, frame]));
|
|
483
489
|
await this.driver.switchTo().parentFrame();
|
|
484
490
|
} catch {
|
|
485
|
-
|
|
486
|
-
|
|
491
|
+
const win = await this.driver.getWindowHandle();
|
|
492
|
+
await this.driver.switchTo().window(win);
|
|
493
|
+
for (const frameElm of frameStack) {
|
|
494
|
+
await this.driver.switchTo().frame(frameElm);
|
|
487
495
|
}
|
|
488
496
|
partials.push("null");
|
|
489
497
|
}
|
|
@@ -496,6 +504,7 @@ var AxeBuilder = class {
|
|
|
496
504
|
async finishRun(partials) {
|
|
497
505
|
const { driver, axeSource, config, option } = this;
|
|
498
506
|
const win = await driver.getWindowHandle();
|
|
507
|
+
await driver.switchTo().window(win);
|
|
499
508
|
try {
|
|
500
509
|
await driver.executeScript(`window.open('about:blank')`);
|
|
501
510
|
const handlers = await driver.getAllWindowHandles();
|
|
@@ -514,7 +523,7 @@ ${error2}`
|
|
|
514
523
|
return res;
|
|
515
524
|
}
|
|
516
525
|
};
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
526
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
527
|
+
0 && (module.exports = {
|
|
528
|
+
AxeBuilder
|
|
529
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -397,7 +397,14 @@ var AxeBuilder = class {
|
|
|
397
397
|
if (runPartialSupported !== true || this.legacyMode) {
|
|
398
398
|
return this.runLegacy(context);
|
|
399
399
|
}
|
|
400
|
-
const
|
|
400
|
+
const { pageLoad } = await this.driver.manage().getTimeouts();
|
|
401
|
+
this.driver.manage().setTimeouts({ pageLoad: 1e3 });
|
|
402
|
+
let partials;
|
|
403
|
+
try {
|
|
404
|
+
partials = await this.runPartialRecursive(context);
|
|
405
|
+
} finally {
|
|
406
|
+
this.driver.manage().setTimeouts({ pageLoad });
|
|
407
|
+
}
|
|
401
408
|
try {
|
|
402
409
|
return await this.finishRun(partials);
|
|
403
410
|
} catch (error2) {
|
|
@@ -431,8 +438,8 @@ var AxeBuilder = class {
|
|
|
431
438
|
/**
|
|
432
439
|
* Get partial results from the current context and its child frames
|
|
433
440
|
*/
|
|
434
|
-
async runPartialRecursive(context,
|
|
435
|
-
if (
|
|
441
|
+
async runPartialRecursive(context, frameStack = []) {
|
|
442
|
+
if (frameStack.length) {
|
|
436
443
|
await axeSourceInject(this.driver, this.axeSource, this.config);
|
|
437
444
|
}
|
|
438
445
|
const frameContexts = await axeGetFrameContext(this.driver, context);
|
|
@@ -440,16 +447,16 @@ var AxeBuilder = class {
|
|
|
440
447
|
await axeRunPartial(this.driver, context, this.option)
|
|
441
448
|
];
|
|
442
449
|
for (const { frameContext, frameSelector, frame } of frameContexts) {
|
|
443
|
-
let switchedFrame = false;
|
|
444
450
|
try {
|
|
445
451
|
assert(frame, `Expect frame of "${frameSelector}" to be defined`);
|
|
446
452
|
await this.driver.switchTo().frame(frame);
|
|
447
|
-
|
|
448
|
-
partials.push(...await this.runPartialRecursive(frameContext));
|
|
453
|
+
partials.push(...await this.runPartialRecursive(frameContext, [...frameStack, frame]));
|
|
449
454
|
await this.driver.switchTo().parentFrame();
|
|
450
455
|
} catch {
|
|
451
|
-
|
|
452
|
-
|
|
456
|
+
const win = await this.driver.getWindowHandle();
|
|
457
|
+
await this.driver.switchTo().window(win);
|
|
458
|
+
for (const frameElm of frameStack) {
|
|
459
|
+
await this.driver.switchTo().frame(frameElm);
|
|
453
460
|
}
|
|
454
461
|
partials.push("null");
|
|
455
462
|
}
|
|
@@ -462,6 +469,7 @@ var AxeBuilder = class {
|
|
|
462
469
|
async finishRun(partials) {
|
|
463
470
|
const { driver, axeSource, config, option } = this;
|
|
464
471
|
const win = await driver.getWindowHandle();
|
|
472
|
+
await driver.switchTo().window(win);
|
|
465
473
|
try {
|
|
466
474
|
await driver.executeScript(`window.open('about:blank')`);
|
|
467
475
|
const handlers = await driver.getAllWindowHandles();
|
|
@@ -480,10 +488,7 @@ ${error2}`
|
|
|
480
488
|
return res;
|
|
481
489
|
}
|
|
482
490
|
};
|
|
483
|
-
if (typeof module === "object") {
|
|
484
|
-
exports = module.exports = AxeBuilder;
|
|
485
|
-
}
|
|
486
|
-
var src_default = AxeBuilder;
|
|
487
491
|
export {
|
|
488
|
-
|
|
492
|
+
AxeBuilder,
|
|
493
|
+
AxeBuilder as default
|
|
489
494
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axe-core/webdriverjs",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.3-alpha.398+9cb50eb",
|
|
4
4
|
"description": "Provides a method to inject and analyze web pages using axe",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"scripts": {
|
|
49
49
|
"prebuild": "rimraf dist",
|
|
50
50
|
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
51
|
-
"test": "mocha --timeout
|
|
52
|
-
"test:esm": "node esmTest.mjs",
|
|
51
|
+
"test": "mocha --timeout 60000 -r ts-node/register 'test/**.spec.ts'",
|
|
52
|
+
"test:esm": "node test/esmTest.mjs",
|
|
53
53
|
"coverage": "nyc npm run test",
|
|
54
54
|
"prepare": "npm run build"
|
|
55
55
|
},
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"functions": 85,
|
|
120
120
|
"lines": 85
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "9cb50ebb6b138cb0aa6b785bc7c826c4b9a21086"
|
|
123
123
|
}
|