2017-10-09 41 views
0

我已經使用雅各布 Api上傳文件自動化Web應用程序與硒,但它會產生UnsatisfiedLinkError。雅各布api文件上傳新,所以請提前幫助和感謝。雅各布api和硒自動化Web應用程序生產UnsatisfiedLinkError

示例腳本: -

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("[email protected]"); 
      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(); 
     } 
    } 
} 

輸出: -

Starting ChromeDriver 2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3) on port 6511 
Only local connections are allowed. 
Oct 09, 2017 10:56:14 AM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end 
Oct 09, 2017 10:56:15 AM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Detected dialect: OSS 
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) 

是新硒自動化,請幫助,並在此先感謝。

回答

0

我有一個非常艱難的時間,直到我明白這一點。祝你好運!

您需要將Jacob dll文件複製到System32文件夾(或SysWOW64文件夾 - 取決於您使用x86 vs x64的JRE/JDK的類型)。

Copy these dll files: 
jacob-1.18-x86.dll 
jacob-1.18-x64.dll 

然後,

paste them in System32 folder: 
    C:\Windows\System32 

If it still doesn't work copy the dll files to: 
    C:\Windows\SysWOW64 
+0

順便說一句,你需要管理員權限的文件複製到這些窗口系統文件夾 – Nash