fix: graceful handling of malformed element declarations; quiet absent-element log

This commit is contained in:
Mathew Sir Guest the best
2026-07-07 22:58:05 -06:00
parent 6af8468730
commit fbb7d4114a
3 changed files with 100 additions and 10 deletions
+28
View File
@@ -46,6 +46,14 @@ class TestElementResolution:
def test_missing_key_returns_none(self):
assert BasePage(make_browser()).find_element_locators("nope") is None
def test_empty_override_still_inherits_ancestors(self):
class Grandchild(ChildPage):
elements = {} # declares nothing; must still resolve ancestor keys
page = Grandchild(make_browser())
assert page.find_element_locators("state") == ("select", ("id", "state"))
assert page.find_element_locators("extra") == ("el", ("id", "extra"))
class TestGetProxy:
def test_typed_dispatch(self):
@@ -89,6 +97,26 @@ class TestGetProxy:
assert isinstance(CustomPage(make_browser())["thing"], MyField)
def test_malformed_locator_missing_accessors_returns_nullfield(self):
class BadPage(Page):
elements = {"x": ("el",)} # missing the accessors half
el = BadPage(make_browser())["x"]
assert isinstance(el, NullField)
assert not el
def test_malformed_accessors_arity_returns_nullfield(self):
class BadPage(Page):
elements = {"x": ("els", ("id",))} # accessors not a (by, value) pair
assert isinstance(BadPage(make_browser())["x"], NullField)
def test_unknown_type_returns_nullfield(self):
class BadPage(Page):
elements = {"x": ("selct", ("id", "x"))} # typo'd type string
assert isinstance(BadPage(make_browser())["x"], NullField)
class TestVerify:
def test_default_verify_is_true(self):