-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
unfortunately in each optgrgoup we have options with the same values...
in the collect/read script
icon_dropdown = 'div.field--name-field-oe-icon select'
icon_text = sb.get_text(f'{icon_dropdown} option[selected]')
icon_value = sb.get_attribute(f'{icon_dropdown} option[selected]', 'value')
dropdown_element = sb.find_element(f'{icon_dropdown} option[selected]')
optgroup_element = dropdown_element.find_element("xpath", "ancestor::optgroup") # parent of selected option
optgroup_label = optgroup_element.get_attribute("label")
in the fill/create-script
icon_dropdown = 'div.field--name-field-oe-icon select'
sb.select_option_by_value(f'{icon_dropdown} optgroup[label="{data["optgroup_label"]}"] option', data['icon_value'])
the last line throws the error:
UnexpectedTagNameException(f"Select only works on <select> elements, not on {webelement.tag_name}")
how do we select an option with a specificed optgroup?
Beta Was this translation helpful? Give feedback.
All reactions
The select_option_by_*
methods only work on <select>
elements with <option>
tags.
You can probably use js_click(selector)
to click what you want, even if the option is hidden.
Replies: 2 comments
-
The select_option_by_*
methods only work on <select>
elements with <option>
tags.
You can probably use js_click(selector)
to click what you want, even if the option is hidden.
Beta Was this translation helpful? Give feedback.
All reactions
-
thnx michael! js_click didn't work somehow, though.
messed aroun dand found that a normal click with xpath worked:
sb.click(f"//optgroup[@label='{label}']/option[@value='{icon}']")
Beta Was this translation helpful? Give feedback.