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

Boolean values in options arg #185

Open afalco103 opened 3 years ago

afalco103 commented 3 years ago

Hey folks, trying to add some rule specifications into the axe 'run' function but am getting the following error

../venv/lib/python3.6/site-packages/axe_selenium_python/axe.py:53: in run
    response = self.selenium.execute_async_script(command)
../venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:659: in execute_async_script
    'args': converted_args})['value']
../venv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x10e914748>
response = {'status': 500, 'value': '{"value":{"error":"javascript error","message":"javascript error: True is not defined\\nJava...fff7082fe65 _pthread_start + 148\\n20  libsystem_pthread.dylib             0x00007fff7082b83b thread_start + 15\\n"}}'}
    axe = Axe(driver)
    axe.inject()
    rules = {"meta-viewport-large": {"enabled": True}}
    results = axe.run(options={'rules': rules})

if I try a rules object like this {"meta-viewport-large": {"enabled": "true"}}, it works. I think it would be helpful to either document that booleans need be formatted like js ones but as strings, or even better have this library automatically convert a Python bool to a stringified js one.