簡體   English   中英

Webdriver io,使用輸入類型=“文件”上傳文件

[英]Webdriver io, file upload using input type=“file”

我正在使用Webdriver.iomochaCoffeeScript上編寫測試。 使用 CoffeeScript 編譯器處理代碼。

在此過程中,我需要使用input type = "file" ( display: none ) 元素將文件上傳到服務器。

我嘗試如下傳輸文件地址(當然,首先使其可見: style.display = 'block' ):

elem_input = $('div.class_1 input.class_2')
browser.elementSendKeys(elem_input.elementId, '/home/user/ ... /test.txt')

找不到文件,控制台出現“找不到文件”的錯誤信息。

我仔細檢查了路徑,是正確的。 如果直接通過界面上傳文件,手動上傳,也沒有問題。

造成這種情況的原因是什么,解決問題的方法是什么?

file_path = browser.uploadFile(FILE_PATH)
# Путь к загружаемому файлу на устройстве
$('div.my_selector').setValue(file_path)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM