Исключение в потоке "main" java.lang.UnsatisfiedLinkError с использованием Java Appium Testing - PullRequest
0 голосов
/ 16 октября 2018

Описание проблемы: - Я столкнулся с проблемой в Java Appium Automation Testing.Я хочу сделать снимок экрана и преобразовать его в файл строкового изображения, а затем проверить тост-сообщение, используя пакеты tesseract ... Я добавил Maven-зависимость jar-файлов tesseract.

Проблема с Java Appium Program

public void readToastMessage(AndroidDriver driver) throws TesseractException, IOException, InterruptedException { 
     Thread.sleep(700);
     this.driver = driver;
      String result = null;
      System.out.println("Capture");
      File file= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
      System.out.println("below the file init");

      //temp code in here..

      SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy__hh_mm_ssaa");
      String screenShotName = "ScreenShot_";

      screenShotName += dateFormat.format(new Date())+".png";


      //temp code till here...


        File dstfile = new File(this.getAndConcatCurrentPath("/src/main/java/Screenshots/"+screenShotName));

        System.out.println("above the try block");
        try {
            FileUtils.copyFile(file, dstfile);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println(" "+dstfile.toString());


  Tesseract instance = Tesseract.getInstance();


File tessDataFolder = LoadLibs.extractTessResources("tessdata");

instance.setDatapath(tessDataFolder.getAbsolutePath());

try {
    String result2 = instance.doOCR(dstfile);
    System.out.println(result);
} catch (TesseractException e) {
    System.err.println(e.getMessage());
}

Ошибка журнала консоли

Capture
below the file init
Printing the user path
above the try block
 /home/connexis/appium/AppiumMobile/src/main/java/Screenshots/ScreenShot_16-Oct-2018__11_19_56AM.png
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': Native library (linux-x86-64/libtesseract.so) not found in resource path ([file:/usr/lib/jvm/java-8-oracle/jre/lib/resources.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/jsse.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/jce.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/cldrdata.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunec.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/jaccess.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunjce_provider.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/zipfs.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/localedata.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/dnsns.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/sunpkcs11.jar, file:/usr/lib/jvm/java-8-oracle/jre/lib/ext/nashorn.jar, file:/home/connexis/appium/AppiumMobile/target/classes/, file:/home/connexis/Documents/lib/ApacheJMeter_core.jar, file:/home/connexis/Documents/lib/ApacheJMeter_java.jar, file:/home/connexis/Documents/lib/avalon-framework-4.1.4.jar, file:/home/connexis/Documents/lib/commons-cli-1.2.jar, file:/home/connexis/Documents/lib/commons-codec-1.2.jar, file:/home/connexis/Documents/lib/commons-httpclient-3.1.jar, file:/home/connexis/Documents/lib/flazr-0.7-RC2.jar, file:/home/connexis/Documents/lib/jcl104-over-slf4j-1.4.2.jar, file:/home/connexis/Documents/lib/jorphan.jar, file:/home/connexis/Documents/lib/log4j-1.2.14.jar, file:/home/connexis/Documents/lib/logkit-2.0.jar, file:/home/connexis/Documents/lib/netty-3.1.5.GA.jar, file:/home/connexis/Documents/lib/oro-2.0.8.jar, file:/home/connexis/Documents/lib/slf4j-api-1.4.2.jar, file:/home/connexis/Documents/lib/slf4j-log4j12-1.4.2.jar, file:/home/connexis/Documents/selenium-java-3.14.0/client-combined-3.14.0.jar, file:/home/connexis/Documents/selenium-java-3.14.0/client-combined-3.14.0-sources.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/byte-buddy-1.8.15.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/commons-codec-1.10.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/commons-exec-1.3.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/commons-logging-1.2.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/guava-25.0-jre.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/httpclient-4.5.5.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/httpcore-4.4.9.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/okhttp-3.10.0.jar, file:/home/connexis/Documents/selenium-java-3.14.0/libs/okio-1.14.1.jar, file:/home/connexis/Downloads/selenium-server-standalone-2.53.0.jar, file:/home/connexis/Documents/java-client-6.1.0.jar, file:/home/connexis/.m2/repository/io/appium/java-client/6.1.0/java-client-6.1.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-support/3.12.0/selenium-support-3.12.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-api/3.12.0/selenium-api-3.12.0.jar, file:/home/connexis/.m2/repository/com/google/code/gson/gson/2.8.4/gson-2.8.4.jar, file:/home/connexis/.m2/repository/org/apache/httpcomponents/httpclient/4.5.5/httpclient-4.5.5.jar, file:/home/connexis/.m2/repository/cglib/cglib/3.2.6/cglib-3.2.6.jar, file:/home/connexis/.m2/repository/org/ow2/asm/asm/6.0/asm-6.0.jar, file:/home/connexis/.m2/repository/org/apache/ant/ant/1.9.6/ant-1.9.6.jar, file:/home/connexis/.m2/repository/org/apache/ant/ant-launcher/1.9.6/ant-launcher-1.9.6.jar, file:/home/connexis/.m2/repository/commons-validator/commons-validator/1.6/commons-validator-1.6.jar, file:/home/connexis/.m2/repository/commons-beanutils/commons-beanutils/1.9.2/commons-beanutils-1.9.2.jar, file:/home/connexis/.m2/repository/commons-digester/commons-digester/1.8.1/commons-digester-1.8.1.jar, file:/home/connexis/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar, file:/home/connexis/.m2/repository/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar, file:/home/connexis/.m2/repository/org/springframework/spring-context/5.0.5.RELEASE/spring-context-5.0.5.RELEASE.jar, file:/home/connexis/.m2/repository/org/springframework/spring-aop/5.0.5.RELEASE/spring-aop-5.0.5.RELEASE.jar, file:/home/connexis/.m2/repository/org/springframework/spring-beans/5.0.5.RELEASE/spring-beans-5.0.5.RELEASE.jar, file:/home/connexis/.m2/repository/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar, file:/home/connexis/.m2/repository/org/springframework/spring-jcl/5.0.5.RELEASE/spring-jcl-5.0.5.RELEASE.jar, file:/home/connexis/.m2/repository/org/springframework/spring-expression/5.0.5.RELEASE/spring-expression-5.0.5.RELEASE.jar, file:/home/connexis/.m2/repository/org/aspectj/aspectjweaver/1.9.1/aspectjweaver-1.9.1.jar, file:/home/connexis/.m2/repository/org/openpnp/opencv/3.2.0-1/opencv-3.2.0-1.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-java/3.14.0/selenium-java-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-chrome-driver/3.14.0/selenium-chrome-driver-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-edge-driver/3.14.0/selenium-edge-driver-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-firefox-driver/3.14.0/selenium-firefox-driver-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-ie-driver/3.14.0/selenium-ie-driver-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-opera-driver/3.14.0/selenium-opera-driver-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-remote-driver/3.14.0/selenium-remote-driver-3.14.0.jar, file:/home/connexis/.m2/repository/org/seleniumhq/selenium/selenium-safari-driver/3.14.0/selenium-safari-driver-3.14.0.jar, file:/home/connexis/.m2/repository/net/bytebuddy/byte-buddy/1.8.15/byte-buddy-1.8.15.jar, file:/home/connexis/.m2/repository/org/apache/commons/commons-exec/1.3/commons-exec-1.3.jar, file:/home/connexis/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar, file:/home/connexis/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar, file:/home/connexis/.m2/repository/com/google/guava/guava/25.0-jre/guava-25.0-jre.jar, file:/home/connexis/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar, file:/home/connexis/.m2/repository/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar, file:/home/connexis/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar, file:/home/connexis/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar, file:/home/connexis/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar, file:/home/connexis/.m2/repository/org/apache/httpcomponents/httpcore/4.4.9/httpcore-4.4.9.jar, file:/home/connexis/.m2/repository/com/squareup/okhttp3/okhttp/3.10.0/okhttp-3.10.0.jar, file:/home/connexis/.m2/repository/com/squareup/okio/okio/1.14.1/okio-1.14.1.jar, file:/home/connexis/.m2/repository/info/cukes/cucumber-java/1.2.5/cucumber-java-1.2.5.jar, file:/home/connexis/.m2/repository/info/cukes/cucumber-core/1.2.5/cucumber-core-1.2.5.jar, file:/home/connexis/.m2/repository/info/cukes/cucumber-html/0.2.3/cucumber-html-0.2.3.jar, file:/home/connexis/.m2/repository/info/cukes/cucumber-jvm-deps/1.0.5/cucumber-jvm-deps-1.0.5.jar, file:/home/connexis/.m2/repository/info/cukes/gherkin/2.12.2/gherkin-2.12.2.jar, file:/home/connexis/.m2/repository/org/apache/poi/poi/3.17/poi-3.17.jar, file:/home/connexis/.m2/repository/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar, file:/home/connexis/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar, file:/home/connexis/.m2/repository/org/apache/poi/poi-ooxml-schemas/3.17/poi-ooxml-schemas-3.17.jar, file:/home/connexis/.m2/repository/org/apache/xmlbeans/xmlbeans/2.6.0/xmlbeans-2.6.0.jar, file:/home/connexis/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar, file:/home/connexis/.m2/repository/com/github/virtuald/curvesapi/1.04/curvesapi-1.04.jar, file:/home/connexis/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar, file:/home/connexis/.m2/repository/com/vimalselvam/cucumber-extentsreport/3.0.2/cucumber-extentsreport-3.0.2.jar, file:/home/connexis/.m2/repository/com/aventstack/extentreports/3.1.3/extentreports-3.1.3.jar, file:/home/connexis/.m2/repository/org/freemarker/freemarker/2.3.23/freemarker-2.3.23.jar, file:/home/connexis/.m2/repository/org/mongodb/mongodb-driver/3.3.0/mongodb-driver-3.3.0.jar, file:/home/connexis/.m2/repository/org/mongodb/bson/3.3.0/bson-3.3.0.jar, file:/home/connexis/.m2/repository/org/mongodb/mongodb-driver-core/3.3.0/mongodb-driver-core-3.3.0.jar, file:/home/connexis/.m2/repository/org/apache/httpcomponents/httpmime/4.5.2/httpmime-4.5.2.jar, file:/home/connexis/.m2/repository/org/jsoup/jsoup/1.9.2/jsoup-1.9.2.jar, file:/home/connexis/.m2/repository/com/asprise/ocr/java-ocr-api/15.3.0.1/java-ocr-api-15.3.0.1.jar, file:/home/connexis/.m2/repository/org/bytedeco/javacpp-presets/tesseract/3.03-rc1-0.11/tesseract-3.03-rc1-0.11.jar, file:/home/connexis/.m2/repository/org/bytedeco/javacpp-presets/leptonica/1.71-0.11/leptonica-1.71-0.11.jar, file:/home/connexis/.m2/repository/org/bytedeco/javacpp-presets/leptonica/1.71-0.11/leptonica-1.71-0.11-linux-x86_64.jar, file:/home/connexis/.m2/repository/org/bytedeco/javacpp/0.11/javacpp-0.11.jar, file:/home/connexis/.m2/repository/org/bytedeco/javacpp-presets/tesseract/3.03-rc1-0.11/tesseract-3.03-rc1-0.11-linux-x86_64.jar, file:/home/connexis/.m2/repository/net/sourceforge/tess4j/tess4j/3.0.0/tess4j-3.0.0.jar, file:/home/connexis/.m2/repository/net/java/dev/jna/jna/4.2.1/jna-4.2.1.jar, file:/home/connexis/.m2/repository/com/github/jai-imageio/jai-imageio-core/1.3.1/jai-imageio-core-1.3.1.jar, file:/home/connexis/.m2/repository/org/ghost4j/ghost4j/1.0.0/ghost4j-1.0.0.jar, file:/home/connexis/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar, file:/home/connexis/.m2/repository/org/apache/xmlgraphics/xmlgraphics-commons/1.4/xmlgraphics-commons-1.4.jar, file:/home/connexis/.m2/repository/com/lowagie/itext/2.1.7/itext-2.1.7.jar, file:/home/connexis/.m2/repository/net/sourceforge/lept4j/lept4j/1.0.1/lept4j-1.0.1.jar, file:/home/connexis/.m2/repository/org/rococoa/rococoa-core/0.5/rococoa-core-0.5.jar, file:/home/connexis/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar, file:/home/connexis/.m2/repository/ch/qos/logback/logback-core/1.1.3/logback-core-1.1.3.jar, file:/home/connexis/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar, file:/home/connexis/.m2/repository/org/slf4j/jul-to-slf4j/1.7.13/jul-to-slf4j-1.7.13.jar, file:/home/connexis/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.13/jcl-over-slf4j-1.7.13.jar, file:/home/connexis/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.13/log4j-over-slf4j-1.7.13.jar])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.<init>(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:412)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:77)
    at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:42)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196)
    at Generic.ReadToastMessage.readToastMessage(ReadToastMessage.java:98)
    at Generic.HandleSwitch.main(HandleSwitch.java:88)

Пожалуйста, помогите мне выяснить, в чем проблема

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...