下面的代码在yaml中,旨在允许支持使用外部Java库执行Java。
当前,我收到一条错误消息,指示找不到该类。
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.sikuli.script.*
我已将jar文件添加到文件夹名称user-jars
,如此处建议的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);
答案 0 :(得分:1)
Java.type()
API要求您指定单个Java类的名称,因此您不能使用通配符。例如:
var Screen = Java.type("org.sikuli.script.Screen");
var screen = new Screen();
screen.click("C:/images/test.png", 0);