'Why isn't Selenium performing this click on an input field?

I am dealing with a seemingly complicated input field: A click on the field also triggers a dropdown menu of previously chosen options. Anyways, I would like to use the input field and let Selenium type in a string. Unfortunately, it won't do it.

This is the code snippet of the input field:

<span class="select2-selection__rendered" id="select2-saved_tribe_venue-container"
role="textbox" aria-readonly="true" title="Create or find venue">

<span class="select2-selection__clear">×</span>

Create or find venue
</span>

I tried the following to put the cursor in the input field:

element = driver.find_element(By.ID, "select2-saved_tribe_venue-container")
element.click()
element.send_keys(...)
...

But this didn't work. ("Can't locate object")

Then I tried

element = driver.find_element(By.ID, "select2-saved_tribe_venue-container")
actions.move_to_element(element).click()

This lets the programme finish successfully (with exit code 0), but won't actually perform the click and also won't type in keys.

What am I missing here? Thank you very much for any recommendations!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source