gpt4 book ai didi

java - Appium Java TestNG Framework>使用 appium main.js 文件通过 Mac 空点异常以编程方式启动 Appium

转载 作者:行者123 更新时间:2023-12-02 10:53:22 29 4
gpt4 key购买 nike

Mac书空气

Java 1.8

Appium桌面版1.8.1

大家好,

我正在构建一个 TestNG 框架,并且我想以编程方式启动我的 appium 桌面服务器以进行测试。所以我决定做的是创建一个 java 测试类来为我调用 appium,我以为我已经编写了正确的代码,但是当我运行它只是为了检查时。出现“空点异常”

<强>1。我做错了什么?

<强>2。我该如何解决这个问题?

这是以编程方式启动appium的代码:

package aappiumLaunchServer;

import java.io.File;

import io.appium.java_client.service.local.AppiumServiceBuilder;

public class LaunchAppium {

private static AppiumServiceBuilder service;

public static void main(String[] args) {
//text
stopAppium();
startAppium();
stopAppium();
}

public static void startAppium() {
System.out.println("Start Appium Server");
service = new AppiumServiceBuilder().usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File ("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js "));
service.build().start();
System.out.println("You can now use Appium Server");
}

public static void stopAppium(){
System.out.println("Appium Server is shutting down....");
try {
service.build().stop();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Your current appium session is terminated... ");
}
System.out.println(" Appium Server has shut down. Thank you for using Appium Server");
}

}

这是来自 eclipse 的消息

appium Server is shutting down....
java.lang.NullPointerExceptionYour current appium session is terminated...
Appium Server has shut down. Thank you for using Appium Server
Start Appium Server

at aappiumLaunchServer.LaunchAppium.stopAppium(LaunchAppium.java:44)
at aappiumLaunchServer.LaunchAppium.main(LaunchAppium.java:16)
Exception in thread "main" io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: The invalid appium node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js has been defined
at io.appium.java_client.service.local.AppiumServiceBuilder.validateNodeStructure(AppiumServiceBuilder.java:102)
at io.appium.java_client.service.local.AppiumServiceBuilder.checkAppiumJS(AppiumServiceBuilder.java:294)
at io.appium.java_client.service.local.AppiumServiceBuilder.createArgs(AppiumServiceBuilder.java:389)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:342)
at aappiumLaunchServer.LaunchAppium.startAppium(LaunchAppium.java:29)
at aappiumLaunchServer.LaunchAppium.main(LaunchAppium.java:17)
Caused by: java.io.IOException: The node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js doesn't exist
at io.appium.java_client.service.local.AppiumServiceBuilder.validateNodeStructure(AppiumServiceBuilder.java:104)
... 5 more

最佳答案

只需在 startAppium 方法中使用 Debug模式尝试创建文件实例

new File ("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js "

这可能会告诉您找不到该文件

关于java - Appium Java TestNG Framework>使用 appium main.js 文件通过 Mac 空点异常以编程方式启动 Appium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51985638/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com