1

Below are my AutoIt Script :

ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","C:\\project\\data\\data.csv")
ControlClick("Open","","Button1")

And Converting the file to exe which is used in the java file as below.

Runtime.getRuntime().exec("C:\\project\\script\\TestAutoIt3.exe");

Now I have to upload 10 files, I have two Questions here:

  1. Can I pass the fileName dynamically and create exe files?
  2. If I want to run this script in others system , the exe file will not work because the project might be in some other path. How can I handle this?

Thanks in Advance?

2
  • Do you want to upload files via webUI? Why not to upload files with selenium only? Commented Feb 14, 2017 at 13:32
  • Can you please let me know how can we do that ? Commented Feb 15, 2017 at 2:07

2 Answers 2

1

To upload file using Selenium + Java you need below code:

ChromeDriver driver = new ChromeDriver();
driver.get("http://page.com");  // This is the page with file upload field
WebElement fileInput = driver.findElement(By.xpath("//input[@type='file']"));
fileInput.sendKeys("C:\\Path\\To\\File.jpg");
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Andresson, But how can we solve if my input type is button and it is opening a browse window?
Yes, it looks like browse or upload button (actually it's <input type="file"> HTML element). It used to receive path to file. And you can handle it in mentioned way. Have you already tried my code?
There was a bug in the product. Now your code work like a champ. Thanks a lot.
0

Please use the answer given from Andersson, So that there is no headache of maintaining autoIt Files(exe/au3). And no extra work needed if you are using your code in someone else systems.

Comments

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.