Skip to content

Commit

Permalink
First batch of UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekdlugosz authored and ruda committed Aug 9, 2023
1 parent 2ea8ce3 commit 302ee2e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 32 deletions.
17 changes: 6 additions & 11 deletions camayoc/ui/models/components/items_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@ class ItemsList(UIPage):

def _get_item_from_current_list(self, name: str):
default_timeout = 5000 # 5s
name_selectors = [
f'div.{class_name}:text-is("{name}")'
for class_name in ("list-group-item-heading", "list-item-name")
]
item_elem = self._driver.locator(",".join(name_selectors))
item_elem_locator = (
"xpath=./ancestor::div[contains(@class, 'list-group-item')]"
"[not(contains(@class, 'list-group-item-text'))]"
)
item_elem = self._driver.locator("css=strong").filter(has_text=name)
item_elem_locator = "xpath=./ancestor::tr[contains(@class, 'quipucords-table__tr')]"
item_elem = item_elem.locator(item_elem_locator)
item_elem.hover(timeout=default_timeout, trial=True)
return item_elem
Expand All @@ -39,12 +32,14 @@ def _get_item_from_current_list(self, name: str):
# by multiple fileds, clearing filters, sorting?).
# But YAGNI tells us this will do for now
def _search_for_item_by_name(self, name: str):
filter_field_button = self._driver.locator("button#filterFieldTypeMenu")
filter_field_button = self._driver.locator(
"div.pf-c-toolbar__content button[id]:has(span.pf-c-select__toggle-arrow)"
).locator("nth=0")
if filter_field_button.text_content() != "Name":
filter_field_button.click()
values_list = filter_field_button.locator("xpath=following-sibling::ul")
values_list.locator("text='Name'").click()
self._driver.fill("input[placeholder$=Name]", name)
self._driver.fill("input[placeholder$=name]", name)
self._driver.keyboard.press("Enter")

def _get_item(self, name: str):
Expand Down
4 changes: 2 additions & 2 deletions camayoc/ui/models/components/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


class PopUp(UIPage):
SAVE_LOCATOR = ".modal-footer button.btn-primary"
CANCEL_LOCATOR = ".modal-footer button.btn-cancel"
SAVE_LOCATOR = ".pf-c-modal-box__footer button.pf-m-primary"
CANCEL_LOCATOR = ".pf-c-modal-box__footer button.pf-m-secondary"
SAVE_RESULT_CLASS = None
CANCEL_RESULT_CLASS = None

Expand Down
2 changes: 1 addition & 1 deletion camayoc/ui/models/components/vertical_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

NavigateToPage = Union[CredentialsMainPage, ScansMainPage, SourcesMainPage]

LEFT_NAV = ".nav-pf-vertical"
LEFT_NAV = "nav.pf-c-nav"


class VerticalNavigation(UIPage):
Expand Down
6 changes: 3 additions & 3 deletions camayoc/ui/models/components/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Wizard(UIPage):


class WizardStep(PopUp, UIPage):
NEXT_STEP_LOCATOR = '.modal-footer button:has-text("Next")'
PREV_STEP_LOCATOR = '.modal-footer button:has-text("Back")'
CANCEL_LOCATOR = ".modal-footer button.btn-cancel"
NEXT_STEP_LOCATOR = '.pf-c-wizard__footer button:has-text("Next")'
PREV_STEP_LOCATOR = '.pf-c-wizard__footer button:has-text("Back")'
CANCEL_LOCATOR = ".pf-c-wizard__footer .pf-c-wizard__footer-cancel button"
NEXT_STEP_RESULT_CLASS = None
PREV_STEP_RESULT_CLASS = None
CANCEL_RESULT_CLASS = None
Expand Down
16 changes: 8 additions & 8 deletions camayoc/ui/models/pages/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class NetworkCredentialForm(CredentialForm):
class FormDefinition:
credential_name = InputField("input[placeholder$=credential]")
authentication_type = SelectField("button#auth-type-select")
username = InputField("input[placeholder$=Username]")
password = InputField("input[placeholder$=Password]")
username = InputField("input[placeholder$=username]")
password = InputField("input[placeholder$=password]")
ssh_key_file = InputField('label:has-text("SSH Key File") + div input')
passphrase = InputField('label:has-text("Passphrase") + div input')
become_method = SelectField("button#become-method-select")
Expand All @@ -59,8 +59,8 @@ def fill(self, data: NetworkCredentialFormDTO):
class SatelliteCredentialForm(CredentialForm):
class FormDefinition:
credential_name = InputField("input[placeholder$=credential]")
username = InputField("input[placeholder$=Username]")
password = InputField("input[placeholder$=Password]")
username = InputField("input[placeholder$=username]")
password = InputField("input[placeholder$=password]")

@overload
def fill(self, data: SatelliteCredentialFormDTO):
Expand All @@ -75,8 +75,8 @@ def fill(self, data: SatelliteCredentialFormDTO):
class VCenterCredentialForm(CredentialForm):
class FormDefinition:
credential_name = InputField("input[placeholder$=credential]")
username = InputField("input[placeholder$=Username]")
password = InputField("input[placeholder$=Password]")
username = InputField("input[placeholder$=username]")
password = InputField("input[placeholder$=password]")

@overload
def fill(self, data: VCenterCredentialFormDTO):
Expand Down Expand Up @@ -104,11 +104,11 @@ def open_add_credential(self, source_type: CredentialTypes) -> CredentialForm:
"class": NetworkCredentialForm,
},
CredentialTypes.SATELLITE: {
"selector": f"{create_credential_button} ~ ul li:nth-of-type(2) a",
"selector": f"{create_credential_button} ~ ul li:nth-of-type(3) a",
"class": SatelliteCredentialForm,
},
CredentialTypes.VCENTER: {
"selector": f"{create_credential_button} ~ ul li:nth-of-type(3) a",
"selector": f"{create_credential_button} ~ ul li:nth-of-type(4) a",
"class": VCenterCredentialForm,
},
}
Expand Down
14 changes: 7 additions & 7 deletions camayoc/ui/models/pages/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@


class CancelWizardPopup(PopUp, AbstractPage):
SAVE_LOCATOR = ".modal-footer button.btn-primary:text-is('Yes')"
CANCEL_LOCATOR = ".modal-footer button.btn-cancel:text-is('No')"
SAVE_LOCATOR = ".pf-c-modal-box__footer button.pf-m-primary:text-is('Yes')"
CANCEL_LOCATOR = ".pf-c-modal-box__footer button.pf-m-secondary:text-is('No')"
SAVE_RESULT_CLASS = Pages.SOURCES
CANCEL_RESULT_CLASS = None

Expand All @@ -41,7 +41,7 @@ class SelectSourceTypeForm(Form, WizardStep, AbstractPage):
CANCEL_RESULT_CLASS = CancelWizardPopup

class FormDefinition:
source_type = RadioGroupField("div.wizard-pf-contents:not(.hidden)")
source_type = RadioGroupField("div.pf-c-wizard__main-body:not(.hidden)")

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -65,7 +65,7 @@ def fill(self, data: SelectSourceDTO):


class SourceCredentialsForm(Form, WizardStep, AbstractPage):
NEXT_STEP_LOCATOR = '.modal-footer button:has-text("Save")'
NEXT_STEP_LOCATOR = '.pf-c-wizard__footer button:has-text("Save")'
NEXT_STEP_RESULT_CLASS = Pages.SOURCES_RESULTS_PAGE
PREV_STEP_RESULT_CLASS = SelectSourceTypeForm
CANCEL_RESULT_CLASS = CancelWizardPopup
Expand Down Expand Up @@ -134,7 +134,7 @@ def fill(self, data: VCenterSourceFormDTO):


class ResultForm(WizardStep, AbstractPage):
NEXT_STEP_LOCATOR = ".modal-footer button.btn-primary"
NEXT_STEP_LOCATOR = ".pf-c-wizard__footer button.pf-m-primary"
NEXT_STEP_RESULT_CLASS = Pages.SOURCES


Expand Down Expand Up @@ -163,7 +163,7 @@ def fill(self, data: NewScanFormDTO):

class SourceListElem(AbstractListItem):
def open_scan(self) -> ScanForm:
scan_locator = 'div.list-view-pf-actions button:has-text("Scan")'
scan_locator = 'td.quipucords-table__td-action button:has-text("Scan")'
self.locator.locator(scan_locator).click()
return ScanForm(client=self._client)

Expand All @@ -185,7 +185,7 @@ def add_source(self, data: AddSourceDTO) -> SourcesMainPage:

@record_action
def open_add_source(self) -> SelectSourceTypeForm:
create_source_button = 'button.btn-primary:has-text("Add")'
create_source_button = 'button.pf-m-primary:has-text("Add")'
self._driver.click(create_source_button)
return self._new_page(SelectSourceTypeForm)

Expand Down

0 comments on commit 302ee2e

Please sign in to comment.