issue_details.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. from selenium.webdriver.common.by import By
  2. from selenium.webdriver.support import expected_conditions
  3. from selenium.webdriver.support.wait import WebDriverWait
  4. from .base import BasePage
  5. from .global_selection import GlobalSelectionPage
  6. class IssueDetailsPage(BasePage):
  7. def __init__(self, browser, client):
  8. super().__init__(browser)
  9. self.client = client
  10. self.global_selection = GlobalSelectionPage(browser)
  11. def visit_issue(self, org, groupid):
  12. self.browser.get(f"/organizations/{org}/issues/{groupid}/")
  13. self.wait_until_loaded()
  14. def visit_issue_activity(self, org, groupid):
  15. self.browser.get(f"/organizations/{org}/issues/{groupid}/activity/")
  16. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  17. def visit_issue_in_environment(self, org, groupid, environment):
  18. self.browser.get(f"/organizations/{org}/issues/{groupid}/?environment={environment}")
  19. self.browser.wait_until(".group-detail")
  20. def visit_tag_values(self, org, groupid, tag):
  21. self.browser.get(f"/organizations/{org}/issues/{groupid}/tags/{tag}/")
  22. self.browser.wait_until('[data-test-id="group-tag-value"]')
  23. def get_environment(self):
  24. return self.browser.find_element(
  25. by=By.CSS_SELECTOR, value='[data-test-id="env-label"'
  26. ).text.lower()
  27. def go_back_to_issues(self):
  28. self.global_selection.go_back_to_issues()
  29. def api_issue_get(self, groupid):
  30. return self.client.get(f"/api/0/issues/{groupid}/")
  31. def go_to_subtab(self, key):
  32. tabs = self.browser.find_element(by=By.CSS_SELECTOR, value='[role="tablist"]')
  33. tabs.find_element(by=By.CSS_SELECTOR, value=f'[role="tab"][data-key="{key}"]').click()
  34. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  35. def open_issue_errors(self):
  36. self.browser.click(".errors-toggle")
  37. self.browser.wait_until(".entries > .errors ul")
  38. def open_curl(self):
  39. self.browser.find_element(by=By.XPATH, value="//a//code[contains(text(), 'curl')]").click()
  40. def resolve_issue(self):
  41. self.browser.click('[aria-label="Resolve"]')
  42. # Resolve should become unresolve
  43. self.browser.wait_until('[aria-label="Resolved"]')
  44. def archive_issue(self):
  45. self.browser.click('[aria-label="Archive"]')
  46. # Ignore should become unresolve
  47. self.browser.wait_until('[aria-label="Archived"]')
  48. def bookmark_issue(self):
  49. self.browser.click('button[aria-label="More Actions"]')
  50. self.browser.wait_until('[data-test-id="bookmark"]')
  51. button = self.browser.element('[data-test-id="bookmark"]')
  52. button.click()
  53. self.browser.click('button[aria-label="More Actions"]')
  54. self.browser.wait_until('[data-test-id="unbookmark"]')
  55. def assign_to(self, user):
  56. assignee = self.browser.find_element(
  57. by=By.CSS_SELECTOR, value='[data-test-id="assigned-to"]'
  58. )
  59. # Open the assignee picker
  60. assignee.find_element(
  61. by=By.CSS_SELECTOR, value='[data-test-id="assignee-selector"]'
  62. ).click()
  63. # Wait for the input to be loaded
  64. wait = WebDriverWait(assignee, 10)
  65. wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, "input")))
  66. assignee.find_element(by=By.TAG_NAME, value="input").send_keys(user)
  67. # Click the member/team
  68. options = assignee.find_elements(by=By.CSS_SELECTOR, value='[role="option"]')
  69. assert len(options) > 0, "No assignees could be found."
  70. options[0].click()
  71. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  72. def find_comment_form(self):
  73. self.browser.wait_until_test_id("note-input-form")
  74. return self.browser.find_element(
  75. by=By.CSS_SELECTOR, value='[data-test-id="note-input-form"]'
  76. )
  77. def has_comment(self, text):
  78. element = self.browser.element('[data-test-id="activity-note-body"]')
  79. return text in element.text
  80. def wait_until_loaded(self):
  81. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  82. self.browser.wait_until_not('[data-test-id="event-errors-loading"]')
  83. self.browser.wait_until_test_id("linked-issues")
  84. self.browser.wait_until_test_id("loaded-device-name")
  85. if self.browser.element_exists("#grouping-info"):
  86. self.browser.wait_until_test_id("loaded-grouping-info")
  87. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  88. def mark_reviewed(self):
  89. self.browser.click('[aria-label="More Actions"]')
  90. self.browser.wait_until('[data-test-id="mark-review"]')
  91. self.browser.click('[data-test-id="mark-review"]')
  92. self.browser.click('[aria-label="More Actions"]')
  93. self.browser.wait_until('[data-test-id="mark-review"][aria-disabled="true"]')