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

Add WebDriver tests for computed label/role #23793

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file.
37 changes: 37 additions & 0 deletions webdriver/tests/get_computed_label/get.py
@@ -0,0 +1,37 @@
import pytest
from six import text_type

from webdriver.error import NoSuchAlertException

from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline


def get_computed_label(session, element):
return session.transport.send(
"GET", "session/{session_id}/element/{element_id}/computedlabel".format(
session_id=session.session_id,
element_id=element))


def test_no_browsing_context(session, closed_window):
response = get_computed_label(session)
assert_error(response, "no such window")


def test_no_user_prompt(session):
response = get_computed_label(session)
assert_error(response, "no such alert")


@pytest.mark.parametrize("html,tag,label", [
("<button>ok</button>", "button", "ok"),
("<button aria-labelledby=\"one two\"></button><div id=one>ok</div><div id=two>go</div>", "button", "ok go"),
("<button aria-label=foo>bar</button>", "button", "foo"),
("<label><input> foo</label>", "input", "foo"),
("<label for=b>foo<label><input id=b>", "input", "foo")])
AutomatedTester marked this conversation as resolved.
Show resolved Hide resolved
def test_get_computed_label(session, html, tag, label):
session.url = inline("{0}".format(tag))
element = session.find.css(tag, all=False)
result = get_computed_label(session, element.id)
assert_success(result, label)
Empty file.
35 changes: 35 additions & 0 deletions webdriver/tests/get_computed_role/get.py
@@ -0,0 +1,35 @@
import pytest
from six import text_type

from webdriver.error import NoSuchAlertException

from tests.support.asserts import assert_error, assert_success
from tests.support.inline import inline


def get_computed_role(session, element):
return session.transport.send(
"GET", "session/{session_id}/element/{element_id}/computedrole".format(
session_id=session.session_id,
element_id=element))


def test_no_browsing_context(session, closed_window):
response = get_computed_role(session, "id")
assert_error(response, "no such window")


def test_no_user_prompt(session):
response = get_computed_role(session, "id")
assert_error(response, "no such alert")


@pytest.mark.parametrize("html,tag,expected", [
("<li role=menuitem>foo", "li", "menu"),
("<input role=searchbox>", "input", "searchbox"),
("<img role=presentation>", "img", "presentation")])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused by this test. By definition, elements with role=presentation should not be included in the a11y tree. So, how is it expected that this test will pass?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, could be a bug in the test. We could remove it here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cookiecrook wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was merged a few years ago, related discussion should be raised as a new issue. This one happens to have been overcome by a later change in #39618

But the new issue @jcsteh may still be relevant against the tests in wai-aria/role/synonym-roles.html… See WPT.fyi results, too.

def test_computed_roles(session, html, tag, expected):
session.url = inline(html)
element = session.find.css(tag, all=False)
result = get_computed_role(session, element.id)
assert_success(result, expected)