我在不使用cmd和桌面应用程序的情况下启动appium服务器,为此我已经编写了代码,但在运行该代码后我得到了这个异常
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Host info: host: 'DESKTOP-SUFA48T', ip: '192.168.0.177'
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.8.1'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[{appium:app=C:\Users\HP\Mobile Testing\MobileTestingAppium\src\test\java\resources\ApiDemos-debug.apk, appium:automationName=UiAutomator2, appium:deviceName=Pixel 2 API 28, platformName=ANDROID}], desiredCapabilities=Capabilities {app: C:\Users\HP\Mobile Testing\..., automationName: UiAutomator2, deviceName: Pixel 2 API 28, platformName: ANDROID}}]
Capabilities {}
我正在使用 andriod 模拟器并在其上运行应用程序
@Test
public void config() throws MalformedURLException {
AppiumDriverLocalService service = new AppiumServiceBuilder()
.withAppiumJS(
new File("C:\\Users\\HP\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js"))
.withIPAddress("127.0.0.1").usingPort(4723).withTimeout(Duration.ofSeconds(300)).build();
service.start();
// Construct the complete URL with the custom base path
URL link = new URL("http://127.0.0.1:4723/wd/hub");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel 2 API 28");
capabilities.setCapability(MobileCapabilityType.APP,
"C:\\Users\\HP\\Mobile Testing\\MobileTestingAppium\\src\\test\\java\\resources\\ApiDemos-debug.apk");
capabilities.setCapability("automationName", "UiAutomator2"); // for Android
AndroidDriver driver = new AndroidDriver(link, capabilities);
driver.quit();
}
这是我的代码
请解决这个问题 预先感谢
在您的移动设备内 - “127.0.0.1:4723”是什么意思? 该服务会在移动设备内运行吗?或者您应该尝试提供运行该服务的计算机的 IP,而不是 localhost/127.0.0.1?