I have used Jacob Api for uploading files on automating web application with selenium, but it produces UnsatisfiedLinkError. Am new for Jacob api to file upload so please help and thanks in advance.
Source Code:-
public class FileUpload {
public static void main(String a[]){
WebDriver driver;
try {
System.setProperty("webdriver.chrome.driver", "/home/ionixx/workspace/IXAutomateNew1/chromedriver/chromedriver_linux");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.navigate().to("http://test/admin/#/login");
driver.findElement(By.id("email")).sendKeys("admin.com");
driver.findElement(By.id("pass")).sendKeys("test");
driver.findElement(By.className("adm-button-action")).click();
Thread.sleep(5000);
driver.findElement(By.xpath("html/body/div[1]/app-root/div/div[2]/div/app-project/div/div/div/div[1]/div/div[1]/h4/button")).click();
driver.findElement(By.xpath("html/body/div[1]/app-root/div/div[2]/div/app-project/div/div/div/div[1]/div/div[2]/div[3]/div[5]/div/div[2]/label[1]")).click();
String workingDir = System.getProperty("user.dir");
final String jacobdllarch = System.getProperty("sun.arch.data.model")
.contains("32") ? "jacob-1.18-x86.dll" : "jacob-1.18-x64.dll";
String jacobdllpath = workingDir + "/" + jacobdllarch;
File filejacob = new File(jacobdllpath);
System.setProperty(LibraryLoader.JACOB_DLL_PATH,
filejacob.getAbsolutePath());
AutoItX uploadWindow = new AutoItX();
String filepath = workingDir + "/home/ionixx/Downloads/123.pdf";
driver.get(filepath);
if (uploadWindow.winWaitActive("File Upload", "", 5)) {
if (uploadWindow.winExists("File Upload")) {
uploadWindow.sleep(100);
uploadWindow.send(filepath);
uploadWindow.controlClick("File Upload", "", "&Open");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
OutPut:-
Only local connections are allowed.
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/ionixx/workspace/Test/jacob-1.18-x64.dll which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/ionixx/workspace/Test/jacob-1.18-x64.dll: /home/ionixx/workspace/Test/jacob-1.18-x64.dll: invalid ELF header (Possible cause: endianness mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:151)
at com.jacob.com.JacobObject.<clinit>(JacobObject.java:110)
at autoitx4java.AutoItX.<init>(AutoItX.java:181)
at FileUpload.main(FileUpload.java:51)