Skip to content

Commit 75c1761

Browse files
committed
tests for target parents
1 parent 0786469 commit 75c1761

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/test_target.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from 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

1313
if 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+
124133
def 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+
142160
def test_iterator() -> None:
143161
locator = (By.ID, "eggs")
144162
target = Target.the("test").located(locator)

0 commit comments

Comments
 (0)