I want to add the text via .send_keys() to the text field input, but after the image file.
However, for some reasons Selenium adds the text always before the image file, even though I added the image file before sending the text input.
For example:
image_button.send_keys(IMAGE_FILEPATH)
textfield.send_keys("text to insert")
The image_button is a input tag I obtained via driver instance, and it is located before the text field. After I sending the image file via .send_keys() method, it shows in the text field.
However, I'm not sure how I can add the text after the image on the text field. Is it possible?
Below is the screenshot and the code is something like the following:
front_textfield, back_textfield = driver.find_elements_by_xpath("//div[@class='richEditor']")
image_front_button, image_back_button = driver.find_elements_by_xpath("//input[@accept='image/*']")
audio_front_button, audio_back_button = driver.find_elements_by_xpath("//input[@accept='audio/*']")
image_front_button.send_keys(image_file)
front_textfield.send_keys(text_front)
audio_front_button.send_keys(audio_file)
I tried running each code one-by-one on my Jupyter notebook, but it failed anyway.
Here is the event associated to the text field:
Hmmm one of the workaround is add the following code, which moves the cursor in the text field.
image_front_button.send_keys(image_file)
for i in range(2):
front_textfield.send_keys(Keys.ARROW_DOWN)
front_textfield.send_keys(Keys.ARROW_RIGHT)
front_textfield.send_keys(text_front)