test(chrome): compare the alias keys and the two derived facts

one page, both resolvers, the ten names that resolved on one host only.
each alias is asked beside the key it resolves through, so the pair is
pinned to the same elements rather than each to itself.

the page grows a container that overflows its box and a neighbour that
does not, because scrollable is derived from the box: without one the
only scrolling element on the page is the document root, whose answer
moves with the window.
This commit is contained in:
pj committed 2026-08-19 10:12:18 +05:30
1 parent 43970686d7
commit 77ee3fc31e
2 files changed
+113 -1

No files matched your search

+104 -1
View File
@@ -127,6 +127,80 @@ func TestSelectors_ResolveTheSameElementsAsTheWebRuntime(t *testing.T) {
object: objectSelector("className", "status"),
want: []string{"nested_row", "nested_badge"},
},
{
// Every name for the accessible label has to name one element. Four
// of the six reached it on one host only: label and
// accessibilityLabel aliased onto accessibilityText alone, which
// the ios sidecar writes and this dump does not, and alias
// expansion is one level; ariaLabel and contentDescription aliased
// onto nothing. accessibilityText was the mirror image, resolving
// against the dump and reaching no DOM attribute of that name.
name: "ariaLabel",
selector: "ariaLabel:login_email",
object: objectSelector("ariaLabel", "login_email"),
want: []string{"login_email"},
},
{
name: "contentDescription",
selector: "contentDescription:login_email",
object: objectSelector("contentDescription", "login_email"),
want: []string{"login_email"},
},
{
name: "label",
selector: "label:login_email",
object: objectSelector("label", "login_email"),
want: []string{"login_email"},
},
{
name: "accessibilityLabel",
selector: "accessibilityLabel:login_email",
object: objectSelector("accessibilityLabel", "login_email"),
want: []string{"login_email"},
},
{
name: "accessibilityText",
selector: "accessibilityText:login_email",
object: objectSelector("accessibilityText", "login_email"),
want: []string{"login_email"},
},
{
// The two ios names for the identifier, which resolved against the
// dump through an alias and against no DOM attribute at all.
name: "identifier",
selector: "identifier:summary_card",
object: objectSelector("identifier", "summary_card"),
want: []string{"summary_card"},
},
{
name: "accessibilityIdentifier",
selector: "accessibilityIdentifier:summary_card",
object: objectSelector("accessibilityIdentifier", "summary_card"),
want: []string{"summary_card"},
},
{
// The ios name for the class, the same way round.
name: "elementType",
selector: "elementType:status",
object: objectSelector("elementType", "status"),
want: []string{"nested_row", "nested_badge"},
},
{
// Compose for Web writes a test tag as data-testid. testTag reached
// the three identifier keys and not that one, and testID reached
// nothing at all, so both named every row of the list on web and no
// element here.
name: "testID",
selector: "testID:customer-row",
object: objectSelector("testID", "customer-row"),
want: []string{"customer_row_a1", "customer_row_b2"},
},
{
name: "testTag",
selector: "testTag:customer-row",
object: objectSelector("testTag", "customer-row"),
want: []string{"customer_row_a1", "customer_row_b2"},
},
{
// A custom element's tag name holds a real tag name inside it, so a
// substring rule answered tag:li with <todo-list> and tag:a with
@@ -260,7 +334,7 @@ func TestSelectors_SecureCombinesWithAnotherKey(t *testing.T) {
}
}
// The other five boolean states are derived from the live element the same way
// The other seven boolean states are derived from the live element the same way
// secure is, and were reached the same wrong way: as a markup attribute, which
// builds [clickable="true"] and matches nothing on any page. The key is
// accepted, so no unknown-key error fires, and the worked example in
@@ -376,6 +450,35 @@ func TestSelectors_BooleanStatesNameWhatBothProducersReport(t *testing.T) {
"state_agree", "state_month", "state_february",
},
},
{
// editable and scrollable are derived the same way and were reached
// the same wrong way, as markup attributes nothing carries.
name: "editable",
selector: "editable:true",
want: []string{"login_email", "login_password", "login_note", "login_terms"},
},
{
name: "not editable",
selector: "editable:false",
scope: "login_form",
want: []string{"login_remember"},
},
{
name: "scrollable",
selector: "scrollable:true",
scope: "scroll_row",
want: []string{"scroll_box"},
},
{
// Both producers state scrollable only where it holds, so the
// container that does not scroll answers to neither value, the way
// an element that is no field at all answers to neither value of
// secure.
name: "not scrollable",
selector: "scrollable:false",
scope: "scroll_row",
want: nil,
},
}
for _, testCase := range cases {
t.Run(testCase.name, func(t *testing.T) {
+9
View File
@@ -43,6 +43,15 @@
<option id="state_february">February</option>
</select>
</div>
<!-- scrollable is derived from the box rather than written by the markup,
and both producers state it only where it holds, so one container here
overflows its box and its neighbour does not. -->
<div id="scroll_row">
<div id="scroll_box" style="height: 20px; overflow: auto">
<div id="scroll_content" style="height: 200px">scrolls</div>
</div>
<div id="scroll_still">still</div>
</div>
<script id="state_script">
document.getElementById("state_remember").checked = true;
document.getElementById("state_agree").checked = false;