Further template refactoring

This commit is contained in:
2021-01-29 18:24:37 +00:00
parent 1eed448828
commit 5d07a1853d
10 changed files with 149 additions and 126 deletions

View File

@@ -190,10 +190,10 @@ class AssetAuditList(AssetList):
def query(self):
return self.find_element(*self._search_text_locator).text
def set_query(self, queryString):
def set_query(self, query):
element = self.find_element(*self._search_text_locator)
element.clear()
element.send_keys(queryString)
element.send_keys(query)
def search(self):
self.find_element(*self._go_button_locator).click()
@@ -206,7 +206,7 @@ class AssetAuditList(AssetList):
except NoSuchElementException:
return None
class AssetAuditModal(Region):
class AssetAuditModal(regions.Modal):
_errors_selector = (By.CLASS_NAME, "alert-danger")
# Don't use the usual success selector - that tries and fails to hit the '10m long cable' helper button...
_submit_locator = (By.ID, "id_mark_audited")
@@ -238,11 +238,6 @@ class AssetAuditList(AssetList):
except NoSuchElementException:
return None
def submit(self):
self.root.find_element(*self._submit_locator).click()
# self.wait.until(lambda x: not self.is_displayed) TODO
self.wait.until(expected_conditions.invisibility_of_element_located((By.ID, 'modal')))
def close(self):
self.page.find_element(*self._close_selector).click()
self.wait.until(expected_conditions.invisibility_of_element_located((By.ID, 'modal')))
@@ -250,19 +245,3 @@ class AssetAuditList(AssetList):
def remove_all_required(self):
self.driver.execute_script("Array.from(document.getElementsByTagName(\"input\")).forEach(function (el, ind, arr) { el.removeAttribute(\"required\")});")
self.driver.execute_script("Array.from(document.getElementsByTagName(\"select\")).forEach(function (el, ind, arr) { el.removeAttribute(\"required\")});")
def __getattr__(self, name):
if name in self.form_items:
element = self.form_items[name]
form_element = element[0](self, self.find_element(*element[1]))
return form_element.value
else:
return super().__getattribute__(name)
def __setattr__(self, name, value):
if name in self.form_items:
element = self.form_items[name]
form_element = element[0](self, self.find_element(*element[1]))
form_element.set_value(value)
else:
self.__dict__[name] = value