Skip to content

Commit

Permalink
update FilteredDropdown locator in widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 committed Feb 11, 2025
1 parent 6e73437 commit ec8126d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion airgun/views/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class operating_system(SatTab):

architecture = FilteredDropdown(id='s2id_host_architecture_id')
operating_system = FilteredDropdown(id='s2id_host_operatingsystem_id')
image = FilteredDropdown(id='s2id_azure_rm_image_id')
image = FilteredDropdown(id='azure_rm_image_id')
root_password = TextInput(id='host_root_pass')

@View.nested
Expand Down
12 changes: 7 additions & 5 deletions airgun/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,19 +1155,21 @@ class FilteredDropdown(GenericLocatorWidget):
"""

selected_value = Text("./a/span[contains(@class, 'chosen')]")
open_filter = Text("./a/span[contains(@class, 'arrow')]")
selected_value = Text("./ancestor::div[1]//span/span[contains(@class, 'rendered')]")
open_filter = Text("./ancestor::div[1]//span/span[contains(@class, 'arrow')]")
clear_filter = Text("./a/abbr")
filter_criteria = TextInput(locator="//div[@id='select2-drop']//input")
filter_criteria = TextInput(
locator="//span[@class='select2-search select2-search--dropdown']//input"
)
filter_content = ItemsList(
"//div[not(contains(@style, 'display: none')) and @id='select2-drop']/ul"
"//span[not(contains(@style, 'display: none')) and @class='select2-results']/ul"
)

def __init__(self, parent, id=None, locator=None, logger=None):
"""Supports initialization via ``id=`` or ``locator=``"""
if (locator and id) or (not locator and not id):
raise ValueError('Please specify either locator or id')
locator = locator or f".//div[contains(@id, '{id}')]"
locator = locator or f".//select[contains(@id, '{id}')]"
super().__init__(parent, locator, logger)

def read(self):
Expand Down

0 comments on commit ec8126d

Please sign in to comment.