Skip to content

Commit

Permalink
feat: add cli flag for running with aom
Browse files Browse the repository at this point in the history
  • Loading branch information
AutoSponge committed Apr 23, 2020
1 parent cf9502e commit 24dea71
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const cli = meow(
--browser, -b Change browsers (default: chromium)
--no-js Disable JavaScript
--no-csp Bypass CSP
--aom, -a Launch with Accessibility Object Model (AOM) enabled
Examples
$ scriptwriter
$ scriptwriter --no-headless
Expand Down Expand Up @@ -53,15 +54,19 @@ const cli = meow(
type: 'boolean',
default: false,
},
aom: {
type: 'boolean',
default: false,
alias: 'a',
},
},
}
);

const { config, browser, headless, csp, js, device } = cli.flags;
const { config, browser, headless, csp, js, device, aom } = cli.flags;
const file = config ? require(resolve(config)) : {};
const use = (path, fallback) => dlv(file, path, fallback);

const scriptwriter = new Scriptwriter({
const normalizedConfig = {
browserType: use('browserType', browser),
launch: {
headless: use('launch.headless', headless),
Expand All @@ -72,5 +77,10 @@ const scriptwriter = new Scriptwriter({
javaScriptEnabled: use('context.javaScriptEnabled', js),
},
device: use('device', device),
});
};
const aomFlag = '--enable-blink-features=AccessibilityObjectModel';
if (aom && !normalizedConfig.launch.args.includes(aomFlag)) {
normalizedConfig.launch.args.push(aomFlag);
}
const scriptwriter = new Scriptwriter(normalizedConfig);
scriptwriter.init();

0 comments on commit 24dea71

Please sign in to comment.