While doing the automation of a web application using selenium webdriver, I came across a situation where i need to Upload a file and proceed further.
We are using Java & Tcl scripting language for this.
Below is my TCL code:
set methodname "uploadFile"
set action "Open"
set file "C:\\\\BATFiles\\\\InsertUsersAccessGroup.txt"
[$_webdriverObj executeScript $methodname $action $file] --> This calls the java method 'executeScript'
Here 'executeScript' is my Java method, coded as below:
public void executeScript(String methodName, String action,String file) {
log.info("Before try block");
try {
log.info("Inside try block");
Runtime r = Runtime.getRuntime();
log.info("Created a runtime object");
Process p = r.exec(new String[]{"C:\\AutoIt\\ModenaAutoIt.exe", methodName, action, file });
log.info("Afte the exec");
p.waitFor();
} catch(Exception IOException) {
log.info("inside exception");
log.info(IOException);
}
}
Even though the file "ModenaAutoIt.exe" is present in the 'C' directory under 'AutoIt' folder, my script is failing with the Java exception
java.io.IOException: Cannot run program "C:\AutoIt\ModenaAutoIt.exe": java.io.IOException: error=2, No such file or directory"
Can someone please help me here?