Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Added Selenium WebDriver Java example to Readme #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ The runner will load the specified file or URL in a headless browser, inject axs
If println() outputs nothing, check if you need to set DesiredCapabilities for your WebDriver (such as loggingPrefs):
https://code.google.com/p/selenium/wiki/DesiredCapabilities

### Run audit from Selenium WebDriver (Java):
try {
JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
URL url = new URL("https://raw.githubusercontent.com/GoogleChrome/" +
"accessibility-developer-tools/stable/dist/js/axs_testing.js");
String script = IOUtils.toString(url.openStream(), StandardCharsets.UTF_8);
jsExecutor.executeScript(script);
String report = (String) jsExecutor.executeScript("var results = axs.Audit.run();" +
"return axs.Audit.createReport(results);");
System.out.println(report);

} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

## Using the results

### Interpreting the result
Expand Down