AutoIt脚本不适用于文件上传,

问题描述 投票:0回答:2

我读了几个博客后就写了以下AutoIT脚本,我的主要要求是在上传框中输入要上传的文件名

WinWaitActive("Choose files","",10)
ControlFocus("Choose files","","Edit1")
Sleep(2000)
ControlSetText("Choose files","","Edit1","dropdowns.jpg")

我的代码没有给出任何错误,但是没有运行脚本,或者没有任何动作。我的脚本调用代码

Runtime.getRuntime().exec("C:/Users/bhavneet.singh/Downloads/scrip1.exe");

注意:默认情况下,我获取基本控制信息,因为没有弹出窗口的信息被加载。

file-upload selenium-webdriver autoit
2个回答
0
投票

以这种方式尝试

#RequireAdmin ;Will give your script a permission elevation (sometimes its needed)
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also

WinWaitActive("Choose file","",10)
ControlFocus("Choose file","","Edit1")
Sleep(2000)
ControlSetText("Choose file","","Edit1","dropdowns.jpg")

0
投票

您的代码看起来不错,只需检查您是否正确编译了autoit脚本。我使用了类似的代码,但它不起作用,然后我意识到我编译错误。我的是32位的,但是我编译为x64,然后我更改为x86并成功了。

© www.soinside.com 2019 - 2024. All rights reserved.