我請求幫助解決我的問題。抱歉有任何錯誤,但這是我第一次提問。我在 selenium 中上傳檔案時遇到問題。我一直在尋找我的問題的解決方案,但我還沒有找到。
這是我的 html 代碼:
<div id="scans-attachments__file__passport-container" >
<input type="hidden" name="scans[attachments__file__passport]" value="" id="scans-attachments__file__passport">
<div data-style-button-remove-item-position="left" data-style-button-process-item-position="right" data-style-load-indicator-position="right" data-style-progress-indicator-position="right" data-style-button-remove-item-align="false" style="height: 76px;">
<input type="file" id="filepond--browser-2ybdvwfwp" name="filepond">
</div>
</div>
我嘗試這樣做:
import os
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
driver.find_element(By.ID, "filepond--browser-2ybdvwfwp").send_keys(os.getcwd() "/image.jpg")
我得到:
response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [id=\\"filepond\\"]...ntent/shared/webdriver/Errors.jsm:393:5\\nelement.find/</<@chrome://remote/content/marionette/element.js:299:16\\n"}}'}
我很抱歉沒有格式化,但我是盲人
uj5u.com熱心網友回復:
錯誤資訊...
"error":"no such element","message":"Unable to locate element: [id=\\"filepond\\"]
...說id = filepond在 DOM 上不可用。我不確定為什么剩余的值會被截斷。請嘗試使用以下元素,
find_element(By.NAME, "filepond")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/367178.html
標籤:硒
