|
1 | 1 | from selenium.webdriver.common.by import By
|
| 2 | +from selenium.webdriver.support.ui import WebDriverWait |
2 | 3 |
|
3 | 4 | import settings
|
4 | 5 | from base.locators import (
|
@@ -58,37 +59,53 @@ class InstitutionAdminDashboardPage(BaseInstitutionPage):
|
58 | 59 |
|
59 | 60 | url_addition = '/dashboard'
|
60 | 61 |
|
61 |
| - identity = Locator(By.CSS_SELECTOR, 'div[data-analytics-scope="Dashboard"]') |
62 |
| - loading_indicator = Locator(By.CSS_SELECTOR, '.ball-scale', settings.LONG_TIMEOUT) |
63 |
| - departments_listbox_trigger = Locator( |
64 |
| - By.CSS_SELECTOR, |
65 |
| - 'div.ember-basic-dropdown-trigger.ember-power-select-trigger._select_tdvp4z', |
| 62 | + identity = Locator(By.CSS_SELECTOR, 'img[alt="Center For Open Science [Test]"]') |
| 63 | + loading_indicator = Locator( |
| 64 | + By.CSS_SELECTOR, '.ball-scale', settings.LONG_TIMEOUT |
66 | 65 | )
|
67 |
| - total_user_count = Locator( |
| 66 | + title_containers = GroupLocator( |
68 | 67 | By.CSS_SELECTOR,
|
69 |
| - 'div.ember-view._panel_1dj7yu._sso-users-connected_1w5vdt > div > div._panel-body_1lht4i > div > h3', |
| 68 | + '._title-container_1d9vmx', |
70 | 69 | )
|
71 |
| - total_project_count = Locator( |
| 70 | + kpi_container = GroupLocator( |
72 | 71 | By.CSS_SELECTOR,
|
73 |
| - 'div.ember-view._panel_1dj7yu._projects_1w5vdt > div > div._panel-body_1lht4i > div > div > h3', |
| 72 | + '._kpi-container_1ge2xx', |
74 | 73 | )
|
75 | 74 | public_project_count = Locator(
|
76 | 75 | By.CSS_SELECTOR, 'div._projects-count_1ky9tx > span:nth-child(1) > strong'
|
77 | 76 | )
|
78 | 77 | private_project_count = Locator(
|
79 | 78 | By.CSS_SELECTOR, 'div._projects-count_1ky9tx > span:nth-child(2) > strong'
|
80 | 79 | )
|
81 |
| - |
82 | 80 | department_options = GroupLocator(
|
83 |
| - By.CSS_SELECTOR, 'ul.ember-power-select-options > li.ember-power-select-option' |
| 81 | + By.CSS_SELECTOR, 'ul._data-list_1d9vmx > li._data-container_1d9vmx' |
84 | 82 | )
|
85 | 83 | user_table_rows = GroupLocator(
|
86 | 84 | By.CSS_SELECTOR,
|
87 | 85 | 'div._table-wrapper_1w5vdt > div > div.ember-view > div > div > table > tbody > tr',
|
88 | 86 | )
|
| 87 | + def get_expanded_total_by_expanded_name(self, department): |
| 88 | + for element in self.department_options: |
| 89 | + name_elem = element.find_element(By.CSS_SELECTOR, "[data-test-expanded-name]") |
| 90 | + if name_elem.text.strip() == department: |
| 91 | + total_elem = element.find_element(By.CSS_SELECTOR, "[data-test-expanded-total]") |
| 92 | + return int(total_elem.text.strip()) |
| 93 | + |
| 94 | + def get_kpi_data_by_kpi_title(self, target_title): |
| 95 | + for container in self.kpi_container: |
| 96 | + title_element = container.find_element(By.CSS_SELECTOR, "[data-test-kpi-title]") |
| 97 | + if title_element.text.strip() == target_title: |
| 98 | + value_element = container.find_element(By.CSS_SELECTOR, "[data-test-kpi-data]") |
| 99 | + return value_element.text.strip() |
| 100 | + |
| 101 | + def click_on_listbox_trigger(self, section_title): |
| 102 | + for section in self.title_containers: |
| 103 | + title_element = section.find_element(By.CSS_SELECTOR, "[data-test-chart-title]") |
| 104 | + if title_element.text.strip() == section_title: |
| 105 | + button = section.find_element(By.CSS_SELECTOR, "[data-test-expand-additional-data]") |
| 106 | + icon = section.find_element(By.CSS_SELECTOR, "[data-test-toggle-icon]") |
| 107 | + button.click() |
| 108 | + WebDriverWait(self.driver, 10).until( |
| 109 | + lambda d: icon.get_attribute("data-icon") == "caret-up" |
| 110 | + ) |
89 | 111 |
|
90 |
| - def select_department_from_listbox(self, department): |
91 |
| - for option in self.department_options: |
92 |
| - if option.text == department: |
93 |
| - option.click() |
94 |
| - break |
|
0 commit comments