Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify arguments to axe.run() #178

Open
dvarrazzo opened this issue Jan 22, 2020 · 1 comment
Open

Clarify arguments to axe.run() #178

dvarrazzo opened this issue Jan 22, 2020 · 1 comment

Comments

@dvarrazzo
Copy link

dvarrazzo commented Jan 22, 2020

Looking at the code, it seems that axe.run() takes arguments as strings representing Javascript objects:

template = (
"var callback = arguments[arguments.length - 1];"
+ "axe.run(%s).then(results => callback(results))"
)
args = ""
# If context parameter is passed, add to args
if context is not None:
args += "%r" % context
# Add comma delimiter only if both parameters are passed
if context is not None and options is not None:
args += ","
# If options parameter is passed, add to args
if options is not None:
args += "%s" % options
command = template % args

This is a surprising interface for a Python object, and I can't find it documented anywhere, or exercised in the unit test. What is the correct way of specifying Axe the following options?

{"runOnly": {"type": "tag", "value": ["wcaga2a"]}}

Maybe you need:

  • an example to show the correct way to call the function
  • if the objects are not strings then json.dumps() them

or maybe I'm reading all wrong?

@ajaysuwalka
Copy link

ajaysuwalka commented Sep 29, 2020

I was also searching for the same and at last found out that you can set them the same way, how they are set in the js like

axe = Axe(driver)
# Inject axe-core javascript into page.
axe.inject()
# Run axe accessibility checks.
results = axe.run(options={
   "runOnly": {
         "type": 'rule',
         "values": ['area-alt', 'aria-allowed-attr','color-contrast', 'valid-lang']
     }
})
# Assert no violations are found
assert len(results["violations"]) == 0, axe.report(results["violations"])

This object can be anything like the examples mentioned #here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants