Skip to content

Forms

Manipulating <select> elements

To manipulate <select> elements, use the method below:

# 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')
// Not yet implemented.

Manipulating <input type="file"> elements

To select a file in an input of type file <input type="file>, use the method below:

# 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"));