88
99from screenpy_selenium import Target , TargetingError
1010
11- from .useful_mocks import get_mocked_browser
11+ from .useful_mocks import get_mocked_browser , get_mocked_target_and_element
1212
1313if TYPE_CHECKING :
1414 from screenpy import Actor
@@ -121,6 +121,15 @@ def test_found_by_raises(Tester: Actor) -> None:
121121 assert test_name in str (excinfo .value )
122122
123123
124+ def test_found_by_parent (Tester : Actor ) -> None :
125+ parent , mocked_element = get_mocked_target_and_element ()
126+ test_locator = (By .ID , "child" )
127+
128+ Target .the ("test" ).located (test_locator ).inside (parent ).found_by (Tester )
129+ mocked_element .find_element .assert_called_once_with (* test_locator )
130+ parent .found_by .assert_called_once_with (Tester )
131+
132+
124133def test_all_found_by (Tester : Actor ) -> None :
125134 test_locator = (By .ID , "baked beans" )
126135 Target .the ("test" ).located (test_locator ).all_found_by (Tester )
@@ -139,6 +148,15 @@ def test_all_found_by_raises(Tester: Actor) -> None:
139148 assert test_name in str (excinfo .value )
140149
141150
151+ def test_all_found_by_parent (Tester : Actor ) -> None :
152+ parent , mocked_element = get_mocked_target_and_element ()
153+ test_locator = (By .ID , "children" )
154+
155+ Target .the ("test" ).located (test_locator ).inside_of (parent ).all_found_by (Tester )
156+ mocked_element .find_elements .assert_called_once_with (* test_locator )
157+ parent .found_by .assert_called_once_with (Tester )
158+
159+
142160def test_iterator () -> None :
143161 locator = (By .ID , "eggs" )
144162 target = Target .the ("test" ).located (locator )
0 commit comments