Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/fixtures/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ def select(self, selector):
def select_all(self, selector):
return self.webdriver.find_elements(by=By.CSS_SELECTOR, value=selector)

def by_text(self, text, tag_name="*"):
"""Helper to select an element with the text it contains.
The element tag can also be provided, to be more explicit.

Example:
<button onclick="doSomething" type="submit">Click me</button>
can be selected with: by_text("Click me", "button")
"""

return self.webdriver.find_element(
By.XPATH, f"//{tag_name}[contains(text(), {text!r})]"
)

def list_download_filenames(self):
self.webdriver.command_executor._commands["SET_CONTEXT"] = (
"POST",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_20_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_edit_instance(registered_agent, browser, ui_url):
comment = browser.select("#inputCommentUpdate").get_attribute("value")
assert "Registered by tests." == comment
Select(browser.select("#selectEnvironmentUpdate")).select_by_visible_text("default")
browser.select("#buttonSubmitUpdate").click()
browser.by_text("Update", "button").click()


def test_download_inventory(registered_agent, browser):
Expand Down