def test_mozillians_search_context(self, selenium): """ Perform search using keystrokes, and run axe on single element of page. """ script_url = 'src/axe.min.js' axe = Axe(selenium, script_url) selenium.get('https://mozillians.org') html = selenium.switch_to.active_element elem = html['value'] elem.send_keys(Keys.TAB) elem.send_keys('mbrandt') elem.send_keys(Keys.ENTER) # wait for page load time.sleep(1) axe = Axe(selenium, script_url) response = axe.execute(selenium, '#main > p.alert > a') # convert array to dictionary violations = dict((k['id'], k) for k in response['violations']) # write result to file axe.write_results('mozillians_search_context.json', violations) # assert response exists assert len(violations) == 0, violations
def test_execute(self, selenium, base_url, pytestconfig): """Run axe against base_url and verify JSON output.""" script_url = './axe_selenium_python/tests/src/axe.min.js' selenium.get(base_url) axe = Axe(selenium, script_url) response = axe.execute(selenium) pytestconfig.axe = axe pytestconfig.test_results = response # convert array to dictionary pytestconfig.violations = dict( (k['id'], k) for k in response['violations']) # assert response exists assert response is not None, response
def test_mozillians_context(self, selenium): """Run axe against a specific element of mozillians.org.""" script_url = 'src/axe.min.js' selenium.get('https://mozillians.org') axe = Axe(selenium, script_url) response = axe.execute(selenium, '#language') # convert array to dictionary violations = dict((k['id'], k) for k in response['violations']) # write result to file axe.write_results('mozillians_context.json', violations) # assert response exists assert len(violations) == 0, violations
def test_mozillians_full(self, selenium): """Run axe against mozillians.org and assert no violations found.""" script_url = 'src/axe.min.js' selenium.get('https://mozillians.org') axe = Axe(selenium, script_url) response = axe.execute(selenium) # convert array to dictionary violations = dict((k['id'], k) for k in response['violations']) # write result to file axe.write_results('mozillians_full.json', violations) # assert response exists assert len(violations) == 0, violations