0

下面的代码在 yaml 中,旨在支持使用外部 Java 库执行 Java。

目前,我收到一条错误消息,指出找不到该类。

Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.sikuli.script.*

user-jars我已按照此处的建议将 jar 文件添加到文件夹名称:https://stackoverflow.com/a/54560878/168617和此处:https : //getopentest.org/docs/scripting-support.html#advanced-concepts

# https://stackoverflow.com/a/54560878/168617
# https://getopentest.org/docs/scripting-support.html#advanced-concepts
description: Login using SikuliX as driver
actors:
  - actor: WEB
    segments:
      - segment: 1
        actions:
          - description: Get content of file
          - script: |
              var Sikuli = Java.type("org.sikuli.script.*")
              var Files = Java.type("java.nio.file.Files");
              var Paths = Java.type("java.nio.file.Paths");
              var System = Java.type("java.lang.System");
              var JavaString = Java.type("java.lang.String");

              var content = new JavaString(Files.readAllBytes(Paths.get("C:/content.txt")), "UTF-8");
              System.out.println(content);
4

1 回答 1

1

API 要求您指定单个 Java 类的Java.type()名称,因此您不能使用通配符。例如:

var Screen = Java.type("org.sikuli.script.Screen");
var screen = new Screen();
screen.click("C:/images/test.png", 0);
于 2019-04-04T15:41:59.977 回答