【发布时间】:2018-07-13 04:26:47
【问题描述】:
我在网页上有输入,允许选择文件:
<input name="amount_name" class="form-control" id="amount_input" aria-invalid="false" type="text" value="">
<input name="file_name" id="file_path" aria-invalid="false" type="file" value="">
<button class="btn btn-success" id="save_btn" type="submit"></button>
我有文件名。我需要输入这个文件名,就像用户选择它一样,然后按“提交”按钮。我这样做:
amount := 10
file_path := "C:\tmp\1.txt"
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := True
wb.Navigate("https://example.com")
;here i fill one input field, it works
wb.document.getElementByID("amount_input").value := amount
;here i need to fill file name. in this edition it opens dialog, but I cant fill it. if i use .value - it just ignored
wb.document.getElementByID("file_path").click()
;it submits form, work fine
wb.document.getElementById("save_btn").click()
【问题讨论】:
-
顺便说一句,如果我从对话框中手动选择文件,那么我可以从 .value 中获取它。但如果我设置 .value,然后读取它 - 它返回空值
标签: autohotkey webpage web-controls