2

Here's a drop zone HTML

<dropzone _ngcontent-c80="" accept="image/jpg,image/jpeg,image/png" _nghost-c81="">
<div _ngcontent-c81="" class="content">
<div _ngcontent-c80="" class="drop-image-icon half-margin-bottom" iconid="drop-image" svg-icon="" vb="0 0 64 48" _nghost-c4="">
<svg _ngcontent-c4="" viewBox="0 0 64 48">
<use _ngcontent-c4="" xlink:href="https://core-stg1.teradek.com/app/kovalyovfortests/studio/assets#drop-image">
</use>
</svg>
</div>
<div _ngcontent-c80="" class="primary">Drop an image here</div>
<div _ngcontent-c80="" class="primary half-margin-top half-margin-bottom">— or —</div>
<a _ngcontent-c80="" class="secondary">Select an image from your computer</a>
</div>
</dropzone>

I tried to send the file with

driver.find_element_by_xpath('//*[@iconid="drop-image"]').send_keys('/home/user/pic/3-1.png')

and get traceback:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

How can I send the file into drop zone using .send_keys?

P.S. It works with

import pyautogui

find_by_xpath('//*[@iconid="drop-image"]').click()

pyautogui.write(/home/user/pic/3-1.png, interval=0.25)
pyautogui.press('return')

1 Answer 1

1

Other alternative sendkey method, you can use Action class:

element = driver.find_element_by_xpath('...')
action = ActionChains(driver)
action.move_to_element(element).send_keys('/home/user/pic/3-1.png').perform()

Following import:

from selenium.webdriver import ActionChains
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately, this does not work for me. The process completed without errors, but the file does not appears in the drop zone.
@Oladuwek What you mean file does not appears in the drop zone ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.