Skip to content

Commit

Permalink
fix more python relative locator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamPDotty committed Sep 23, 2024
1 parent dc6b83e commit 9b51bc2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions py/test/selenium/webdriver/support/relative_by_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def test_no_such_element_is_raised_rather_than_index_error_by_locator(driver, pa

def test_near_locator_should_find_near_elements(driver, pages):
pages.load("relative_locators.html")
rect1 = driver.find_element(By.ID, "rect1")
rect = driver.find_element(By.ID, "rect1")

el = driver.find_element(locate_with(By.ID, "rect2").near(rect1))
el = driver.find_element(locate_with(By.ID, "rect2").near(rect))

assert el.get_attribute("id") == "rect2"

Expand All @@ -174,10 +174,10 @@ def test_near_locator_should_find_near_elements_by_locator(driver, pages):

def test_near_locator_should_not_find_far_elements(driver, pages):
pages.load("relative_locators.html")
rect2 = driver.find_element(By.ID, "rect2")
rect = driver.find_element(By.ID, "rect2")

with pytest.raises(NoSuchElementException) as exc:
driver.find_element(locate_with(By.ID, "rect4").near(rect3))
driver.find_element(locate_with(By.ID, "rect4").near(rect))

assert "Cannot locate relative element with: {'id': 'rect4'}" in exc.value.msg

Expand All @@ -193,17 +193,17 @@ def test_near_locator_should_not_find_far_elements_by_locator(driver, pages):

def test_near_locator_should_find_far_elements(driver, pages):
pages.load("relative_locators.html")
rect3 = driver.find_element(By.ID, "rect3")
rect = driver.find_element(By.ID, "rect2")

el = driver.find_element(locate_with(By.ID, "rect4").near(rect3, 100))
el = driver.find_element(locate_with(By.ID, "rect4").near(rect, 100))

assert el.get_attribute("id") == "rect4"


def test_near_locator_should_find_far_elements_by_locator(driver, pages):
pages.load("relative_locators.html")

el = driver.find_element(locate_with(By.ID, "rect4").near({By.ID: "rect3"}, 100))
el = driver.find_element(locate_with(By.ID, "rect4").near({By.ID: "rect2"}, 100))

assert el.get_attribute("id") == "rect4"

Expand Down

0 comments on commit 9b51bc2

Please sign in to comment.