我想在Selenium WebDriver中使用AutoIt上传文件。我是AutoIt代码,用于在窗口提示中粘贴文件路径并单击打开按钮。
但我的问题是点击“浏览”后的问题。按钮使用下面的代码,文件上传的窗口提示出现,我的代码没有从那一点移动到下一行,我调用自动执行文件。
driver.findElement(By.xpath("//div[@class='field-group file-inputlist']//div[@class='field-group ']//input")).click();
我的AutoIt代码是
WinWait("[CLASS:#32770]","",10) ;
//Set input focus to the edit control of Upload window using the handle returned by WinWait
ControlFocus("File Upload","","Edit1") Sleep(2000) ;
//Set the File name text on the Edit field
ControlSetText("File Upload", "", "Edit1", $CmdLine[1]) Sleep(2000) ;
//Click on the Open button
ControlClick("File Upload", "","Button1");
Eclipse甚至没有抛出任何错误或异常。代码在浏览器单击“浏览”按钮时停止,并打开一个窗口提示。
注意:如果我手动关闭窗口提示,则会从那里继续执行代码。
答案 0 :(得分:0)
文件上传需要遵循的步骤是:
尝试步骤2 - 4的示例代码
示例代码:
WinWait("File Upload")
WinActivate("File Upload")
ControlSetText("File Upload", "", "[CLASS:Edit;INSTANCE:1]",$CmdLine[1])
;ControlSetText("Choose", "", "[CLASS:Edit;INSTANCE:1]", "*****Absolute File Path********")
ControlClick("File Upload", "", "[CLASS:Button;TEXT:&Open]")