简体   繁体   English

使用AutoIt通过Selenium WebDriver中的窗口提示上载文件

[英]Upload file via window prompt in Selenium WebDriver using AutoIt

I wanted to upload the file using AutoIt in Selenium WebDriver. 我想在Selenium WebDriver中使用AutoIt上传文件。 I've AutoIt code for pasting the path of the file in window prompt and clicking on the open button. 我有AutoIt代码,用于在窗口提示中粘贴文件的路径,然后单击打开按钮。

but my problem is after clicking on the 'Browse' button using the below code, window prompt for file upload is appearing and my code is not moving from that point to next line where Im calling autoit executable file. 但是我的问题是使用下面的代码单击“浏览”按钮后,出现文件上传的窗口提示,并且我的代码没有从该点移动到下一个我调用自动可执行文件的行。

driver.findElement(By.xpath("//div[@class='field-group file-inputlist']//div[@class='field-group ']//input")).click();

My AutoIt Code is 我的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 is not even throwing any error or exception. Eclipse甚至没有抛出任何错误或异常。 Code stops at the point where the browser clicks on Browse button and a window prompt opens. 代码停止在浏览器单击“浏览”按钮并打开窗口提示的位置。

Note: If I close the Window Prompt Manually then the Code is continued from there. 注意:如果我手动关闭窗口提示,则代码将从此处继续。

Steps to be followed for File Upload are: 文件上传要遵循的步骤是:

  1. Click on Browse button 点击浏览按钮
  2. Wait for Window to open 等待窗口打开
  3. Wait for the window to be active(editable) 等待窗口处于活动状态(可编辑)
  4. Set control & then choose file to upload 设置控件,然后选择要上传的文件

try sample code for step 2 - 4 尝试步骤2-4的示例代码

Sample code: 样例代码:

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]")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM