0

我已经让 Marathon JAVA 驱动程序在 Eclipse 中工作,当我从 Eclipse 运行代码时它工作正常。但是,当我将项目导出为可运行的 JAR 文件,然后执行 JAR 文件时,出现以下错误并且应用程序未启动。

在 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61) 引起:java.lang.NullPointerException at net.sourceforge.marathon.javadriver.JavaProfile.(JavaProfile.java:205)

import java.io.IOException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import net.sourceforge.marathon.javadriver.JavaDriver;
import net.sourceforge.marathon.javadriver.JavaProfile;
import net.sourceforge.marathon.javadriver.JavaProfile.LaunchMode;
import net.sourceforge.marathon.javadriver.JavaProfile.LaunchType;

public class SwingAutomationSample {
    public static JavaDriver driver;
    public static JavaProfile profile;

@BeforeClass 
public void setUp() throws IOException {

        try {           
        profile = new JavaProfile(LaunchMode.EXECUTABLE_JAR);                   
        profile.setLaunchType(LaunchType.FX_APPLICATION);                
        profile.setExecutableJar("C:/Users/KarthikRaja/Desktop/Projects/xxyy.jar");
        profile.setWorkingDirectory("C:/Users/KarthikRaja/Desktop/Projects");      
        driver = new JavaDriver(profile);      
        }catch(Exception e) {
            System.out.println("java driver error ------------ " + e.toString());
        }
}

@Test
public void Form15CBFill() throws Exception {
    System.out.println("Inside Test Class");
    }
}```
4

2 回答 2

1

Marathon Java 驱动程序使用它的 jar 文件,以便它可以设置 JAVA_TOOL_OPTIONS。所以它需要 jar 文件在文件系统中是可评估的。

请检查JavaProfile.java行号 204 以供参考。

为了快速修复导出 marathon jar 并将它们添加到类路径并编写批处理脚本来执行测试用例。

于 2021-05-10T07:10:49.683 回答
1

@Aditya,再次感谢您为我指明正确的方向。以下步骤为我解决了这个问题。

  1. 下载 selenium-standalone-jar 并将其添加到项目构建路径中
  2. 正如 Aditya 所建议的那样,将项目导出为可运行的 JAR 文件,并带有选项“将所需的库复制到生成的 JAR 旁边的子文件夹中”
  3. 在导出的 JAR 中,确保清单文件在类路径中包含 selenium-standalone-jar 和其他依赖项

这为我解决了这个问题。

于 2021-05-11T09:23:25.350 回答