Class: Sa11y::Analyze
- Inherits:
-
Object
- Object
- Sa11y::Analyze
- Defined in:
- lib/sa11y/analyze.rb
Overview
Analyzes Current Webpage with axe™ Accessibility Tool from Deque
Constant Summary collapse
- AXE_RUN_SCRIPT =
github.com/dequelabs/axe-core-maven-html/blob/61447b/src/main/java/com/deque/html/axecore/selenium/ AxeBuilder.java#L83-L95 Copyright © 2020 Deque Systems Inc.,
<<~AXE var callback = arguments[arguments.length - 1];var context = typeof arguments[0] === 'string' ? JSON.parse(arguments[0]) : arguments[0];context = context || document; var options = JSON.parse(arguments[1]);axe.run(context, options, function (err, results) { { if (err) { throw new Error(err); } callback(results); }}); AXE
- IFRAME_ALLOWED_SCRIPT =
github.com/dequelabs/axe-core-maven-html/blob/61447b/src/main/java/com/deque/html/axecore/selenium/ AxeBuilder.java#L97 Copyright © 2020 Deque Systems Inc.,
"axe.configure({ allowedOrigins: ['<unsafe_all_origins>'] });"
Instance Attribute Summary collapse
-
#cross_origin ⇒ Object
Returns the value of attribute cross_origin.
-
#frames ⇒ Object
Returns the value of attribute frames.
-
#js_lib ⇒ Object
Returns the value of attribute js_lib.
Instance Method Summary collapse
-
#initialize(driver, js_lib: nil, frames: true, cross_origin: false) ⇒ Analyze
constructor
A new instance of Analyze.
- #results ⇒ Object
Constructor Details
#initialize(driver, js_lib: nil, frames: true, cross_origin: false) ⇒ Analyze
Returns a new instance of Analyze.
31 32 33 34 35 36 |
# File 'lib/sa11y/analyze.rb', line 31 def initialize(driver, js_lib: nil, frames: true, cross_origin: false) @driver = driver @js_lib = js_lib || File.read(File.("../scripts/axe.min.js", __dir__)) @frames = frames @cross_origin = cross_origin end |
Instance Attribute Details
#cross_origin ⇒ Object
Returns the value of attribute cross_origin.
14 15 16 |
# File 'lib/sa11y/analyze.rb', line 14 def cross_origin @cross_origin end |
#frames ⇒ Object
Returns the value of attribute frames.
14 15 16 |
# File 'lib/sa11y/analyze.rb', line 14 def frames @frames end |
#js_lib ⇒ Object
Returns the value of attribute js_lib.
14 15 16 |
# File 'lib/sa11y/analyze.rb', line 14 def js_lib @js_lib end |
Instance Method Details
#results ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/sa11y/analyze.rb', line 38 def results if @frames @driver.switch_to.default_content manage_frames else @driver.execute_script(@js_lib) end @driver.execute_async_script(AXE_RUN_SCRIPT, nil, "{}") end |