LaVague icon indicating copy to clipboard operation
LaVague copied to clipboard

Error in code execution: 'WebElement' object has no attribute 'select_by_value'

Open y22ma opened this issue 10 months ago • 0 comments

Describe the bug It seems that the generated code is trying to call specific function from the Select class (select_by_value), but driver.find_element function returns a WebElement class. It's missing the conversion to the Select class.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://ticketsmuseums.comune.fi.it/1_museo-di-palazzo-vecchio/'
  2. Type in instruction: select 1 whole ticket' and run the query
  3. see generated code below:
# Let's proceed step by step.
# First we need to identify the select element for whole tickets and choose the option with value '1'.

# Based on the HTML provided, the select element for whole tickets can be identified using the name "search_museo_int"
# Let's use this name with Selenium to identify the select element
select_whole_tickets = driver.find_element(By.XPATH, "//select[@name='search_museo_int']")

# Then we select the option with value '1'
select_whole_tickets.select_by_value('1')

and error Error in code execution: 'WebElement' object has no attribute 'select_by_value'

Expected behavior Generate and run the following code:

from selenium.webdriver.support.ui import Select
select_whole_tickets = Select(driver.find_element(By.XPATH, "//select[@name='search_museo_int']"))

# Then we select the option with value '1'
select_whole_tickets.select_by_value('1')

Work Around Add Select class to the action_engine.py imports works, probably need other classes of the sort as well.

y22ma avatar Apr 15 '24 19:04 y22ma