You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to select element in drop-down list, like "Select" method in Selenium, but only get result before select.
How I modify code below?
(Run in google colab)
# Find the select element
select = r.html.find("select")
if len(select) > 0:
print(select[0]) # <Element 'select' ... >
# Extract all options from the select element
options = select[0].find("option")
print("Available options:")
for i, option in enumerate(options):
value = option.attrs.get("value", "")
text = option.text
is_selected = "selected" in option.attrs
print(f"Option {i + 1}: Value='{value}', Text='{text}', Selected={is_selected}")
# Simulate selecting an option (e.g., the option with value "3")
simulated_value = "3"
selected_option = next((opt for opt in options if opt.attrs.get("value") == simulated_value), None)
if selected_option:
print(f"Simulated selection: Value='{simulated_value}', Text='{selected_option.text}'")
else:
print(f"No option with value='{simulated_value}' found.")
else:
print("No <select> element found.")
I want to select element in drop-down list, like "Select" method in Selenium, but only get result before select.
How I modify code below?
(Run in google colab)
The text was updated successfully, but these errors were encountered: