We have a script to upload image files in web application (like uploading resume in job portal) we are using Auto IT to do the same(below are the code), but when we run the same script in remote (node) machine via selenium Grid, the path (Location of the image file) is not updated in the Open dialogue box of remote machine, instead script is always focusing in local machine (hub) to update the path. we are not sure how to handle this. Could you please help us on this? I can able to launch the drivers in node machine and i can process for execution but i am failing in updating the path in open window dialogue box.
I have used below code to upload the image in our portal. but this code is fine in HUB machine but not in remote machine. As my whole control is in hub machine so when this popup opens up in remote machine, that is it, the script is not updating the path in open window dialogue box.
//**********************************************\\
public boolean uploadFile( WebDriver driver , String uploadfileName ,
String tcName , ExtentTest test , String browser ) {
String jacobDllVersionToUse;
if ( jvmBitVersion().contains( "32" ) ) {
jacobDllVersionToUse = "jacob-1.18-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-x64.dll";
}
File file = new File( System.getProperty( "user.dir" ) + "\\AutoItLib\\" , jacobDllVersionToUse );
System.out.println( "Path AutoLib: " + file );
System.setProperty( LibraryLoader.JACOB_DLL_PATH , file.getAbsolutePath() );
System.out.println( "Absolute Path: " + file );
AutoItX x = new AutoItX();
try {
Thread.sleep( 1000 );
if ( browser.trim().equalsIgnoreCase( "chrome" ) ) {
x.winWait( "[Title:Open]" , "" , 15 );
x.controlFocus( "[Title:Open]" , "" , "Edit1" );
File url = new File( System.getProperty( "user.dir" ) + "\\Uploadfiles\\" + uploadfileName );
String name = FilenameUtils.getExtension( uploadfileName );
if ( url.exists() && ( name.equalsIgnoreCase( "png" ) || name.equals( "pdf" ) || name
.equals( "tiff" ) ) ) {
x.ControlSetText( "[TITLE:Open]" , "" , "Edit1" , url.toString() );
Thread.sleep( 1000 );
x.controlClick( "[Title:Open]" , "" , "Button1" );
Thread.sleep( 1000 );
return true;
}
else {
x.controlClick( "[Title:Open]" , "" , "Button2" );
Thread.sleep( 1000 );
test.log( LogStatus.FAIL , "Unable to upload File" + uploadfileName );
return false;
}
}
else if ( browser.trim().equalsIgnoreCase( "firefox" ) ) {
x.winWait( "[Title:File Upload]" , "" , 15 );
x.controlFocus( "[Title:File Upload]" , "" , "Edit1" );
x.ControlSetText( "[TITLE:File Upload]" , "" , "Edit1" ,
System.getProperty( "user.dir" ) + "\\Uploadfiles\\" + uploadfileName );
Thread.sleep( 1000 );
x.controlClick( "[Title:File Upload]" , "" , "Button1" );
Thread.sleep( 1000 );
return true;
}
else if ( browser.trim().equalsIgnoreCase( "ie" ) )
x.winWait( "[Title:Choose File to Upload]" , "" , 20 );
x.controlFocus( "[Title:Choose File to Upload]" , "" , "Edit1" );
x.ControlSetText( "[TITLE:Choose File to Upload]" , "" , "Edit1" ,
System.getProperty( "user.dir" ) + "\\Uploadfiles\\" + uploadfileName )
x.controlClick( "[Title:Choose File to Upload]" , "" , "Button1" );
return true;
}
}
catch ( Exception e ) {
}
return false;
}
private String jvmBitVersion() {
return System.getProperty( "sun.arch.data.model" );
}
添加下载属性