1

I wanted to upload the file using AutoIt in Selenium WebDriver. I've AutoIt code for pasting the path of the file in window prompt and clicking on the open button.

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

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. 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.

2
  • 1
    Could you please simply edit your post to add some of your autoit code to make it easier to understand? The size of the comments field messes up your format. Also am I right that you refer to the same window with "[CLASS:#32770]" and "File Upload"? Maybe unify the two? And to make sure you know which line is holding up your script you can add like ConsoleWriteLine("1") with ascending numbers after each command and see which one is the last in the console. Commented Jul 20, 2014 at 10:15
  • I think your autoit die here $CmdLine[1], try to hardcode a valid file location then try your script again. Commented Jul 22, 2014 at 3:42

1 Answer 1

1

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

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]")
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the Code Vijayakumar . I have the AutoIt code . But My problem is once my selenium java code clicks on the browse button. Window Prompt opens. There my code stops without moving to next line. Its not moving to the next line until I close the Window prompt manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.