python硒。上载没有输入标记的文件

2024-05-29 05:54:28 发布

您现在位置:Python中文网/ 问答频道 /正文

这是一个放置区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>

我试图用电子邮件发送文件

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

并获得回溯:

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

如何使用.send\u键将文件发送到放置区域

附言,它与

import pyautogui

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

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

Tags: svgmarginimagedivpngclassdrophalf
1条回答
网友
1楼 · 发布于 2024-05-29 05:54:28

其他可选的sendkey方法,您可以使用Action类:

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

以下内容:

from selenium.webdriver import ActionChains

相关问题 更多 >

    热门问题