Saltar a contenido

Formularios

Manipulación de elementos <select>

Para manipular elementos <select>, utiliza el siguiente método:

# Import element_as_select function.
from botcity.web.util import element_as_select

# Get the element.
select_element = bot.find_element(selector='select', by=By.ID)

# Converting the element to a select element.
select_element = element_as_select(select_element)

# Select the option by index.
select_element.select_by_index(index=0)

# Select the option by value.
select_element.select_by_value(value='ABC')

# Select the option with the text that is visible to the user.
select_element.select_by_visible_text(text='ABC')
// Aún no implementado.

Manipulación de elementos <input type="file">

Para seleccionar un archivo en un input de tipo file <input type="file>, utiliza el siguiente método:

# Get the element.
input_file = bot.find_element('file', By.ID)

# select the file.
bot.set_file_input_element(element=input_file, file_path='PATH_TO_FILE_HERE')
// Get the element.
WebElement fileInput = findElement(By.id("file"));

// Get the file
setFileInputElement(fileInput, new File("PATH_TO_FILE_HERE"));