Skip to content

Commit 3621fe2

Browse files
committed
Adding a new by_text element selector helper in tests
1 parent 5a8a700 commit 3621fe2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tests/fixtures/ui.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def select(self, selector):
9191
def select_all(self, selector):
9292
return self.webdriver.find_elements(by=By.CSS_SELECTOR, value=selector)
9393

94+
def by_text(self, text, tag_name="*"):
95+
return self.webdriver.find_element(
96+
by=By.XPATH, value=f"//{tag_name}[contains(text(), '{text}')]"
97+
)
98+
9499
def list_download_filenames(self):
95100
self.webdriver.command_executor._commands["SET_CONTEXT"] = (
96101
"POST", "/session/$sessionId/moz/context")

tests/test_20_inventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_edit_instance(registered_agent, browser, ui_url):
5252
browser.select("#inputNotify").click()
5353
comment = browser.select("#inputComment").get_attribute('value')
5454
assert "Registered by tests." == comment
55-
browser.select("#buttonSubmit").click()
55+
browser.by_text("Update", "button").click()
5656

5757

5858
def test_download_inventory(registered_agent, browser):

0 commit comments

Comments
 (0)