mozilla-services / axe-selenium-python

aXe Selenium Integration python package
https://pypi.python.org/pypi/axe-selenium-python/
Mozilla Public License 2.0
58 stars 50 forks source link

Clarify arguments to `axe.run()` #178

Open dvarrazzo opened 4 years ago

dvarrazzo commented 4 years ago

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

https://github.com/mozilla-services/axe-selenium-python/blob/270c8cd5aed76e31d8c9086e397a487126425026/axe_selenium_python/axe.py#L36-L52

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:

or maybe I'm reading all wrong?

ajaysuwalka commented 3 years ago

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