Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
a11y-tester
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robert A Fentress
a11y-tester
Commits
e3babaa0
Commit
e3babaa0
authored
4 years ago
by
Rob Fentress
Browse files
Options
Downloads
Patches
Plain Diff
improved structure of views
parent
868e553a
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/analyze.js
+38
-19
38 additions, 19 deletions
lib/analyze.js
with
38 additions
and
19 deletions
lib/analyze.js
+
38
−
19
View file @
e3babaa0
...
...
@@ -145,40 +145,59 @@ const views = async (url) => {
puppeteer
.
devices
[
'
iPhone 5
'
]
];
try
{
const
page
=
await
browser
.
newPage
();
// Create a new page
await
page
.
setBypassCSP
(
true
);
page
.
setDefaultNavigationTimeout
(
0
);
const
navigationPromise
=
page
.
waitForNavigation
();
// Set a promise awaiting page navigation
cliReporter
(
pageCol
(
'
Page:
'
+
url
));
await
page
.
goto
(
url
,
{
waitUntil
:
'
domcontentloaded
'
});
// Load the page you want to test
await
navigationPromise
;
// Wait for the page to load
const
builder
=
new
AxePuppeteer
(
page
);
// Create instance of AxePuppeteer
builder
.
withTags
([
'
wcag2a
'
,
'
wcag2aa
'
]);
for
(
let
device
of
devices
)
{
cliReporter
(
viewportCol
(
device
.
name
));
await
page
.
emulate
(
device
);
var
results
=
await
builder
.
analyze
();
// Check accessibility of page, returning axe results object
var
title
=
await
page
.
title
();
results
.
title
=
title
||
url
;
logResults
(
results
);
myResults
.
push
(
results
);
try
{
await
page
.
emulate
(
device
);
cliReporter
(
viewportCol
(
device
.
name
));
await
page
.
goto
(
url
);
// Load the page you want to test
const
builder
=
new
AxePuppeteer
(
page
);
// Create instance of AxePuppeteer
builder
.
withTags
([
'
wcag2a
'
,
'
wcag2aa
'
]);
var
results
=
await
builder
.
analyze
();
// Check accessibility of page, returning axe results object
var
title
=
await
page
.
title
();
results
.
title
=
title
||
url
;
logResults
(
results
);
myResults
.
push
(
results
);
}
catch
(
err
)
{
cliReporter
(
error
(
'
SOMETHING WENT WRONG WHILE LOOPING THROUGH DEVICES
'
));
myResults
.
push
({
ERROR
:
{
name
:
err
.
name
,
message
:
err
.
message
,
stack
:
err
.
stack
},
url
:
url
,
device
:
device
});
}
}
await
page
.
close
();
}
catch
(
err
)
{
cliReporter
(
error
(
'
SOMETHING WENT WRONG WHILE TESTING THE PAGE
'
));
myResults
.
push
({
ERROR
:
{
name
:
err
.
name
,
message
:
err
.
message
,
stack
:
err
.
stack
},
url
:
url
});
}
finally
{
await
page
.
close
();
await
browser
.
close
();
console
.
error
(
err
);
return
{
error
:
err
};
return
myResults
;
}
await
browser
.
close
();
return
myResults
;
}
const
site
=
async
(
urls
)
=>
{
let
myResults
=
[];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment