gpt4 book ai didi

java - Appium _org.openqa.selenium.SessionNotCreatedException

转载 作者:行者123 更新时间:2023-12-02 01:03:30 30 4
gpt4 key购买 nike

image of my project structure and apk location

我正在运行适用于 Android 应用程序的 appium 脚本。

但它根本没有运行。

我已经在我的 Maven 项目中添加了运行测试所需的所有依赖项。

添加下面的所有代码。

请检查并帮助我。

启动类

      package TestCases.Project_Entry;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;

public class launch {

AndroidDriver<AndroidElement> driver;

public AndroidDriver<AndroidElement> capabilities() throws MalformedURLException {

// TODO Auto-generated method stub
File appDir = new File("src");
File app = new File(appDir, "app-staging-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Palak");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "25");
capabilities.setCapability("autoGrantPermissions", true);

capabilities.setCapability("--session-override", true);
driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

return driver;
}

}
  1. 我已经尝试过,重新启动 eclipse。
  2. 添加自动化名称作为 ui automator 2
    package TestCases.Project_Entry;

import java.io.IOException;
import java.net.MalformedURLException;

import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.*;

import PageObject.loginObjects;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;

public class loginTestCases extends launch {
AndroidDriver<AndroidElement> driver;

@BeforeTest
public void openapp() throws MalformedURLException {
capabilities();
}



@Test
public void log() {


driver.findElementById("versionx.entryPoint:id/ed_verificationEmail").sendKeys("213214");

}

}

错误显示:-

>[RemoteTestNG] detected TestNG version 7.0.0
FAILED CONFIGURATION: @BeforeTest openapp
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original


>===============================================
Default test
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 0
===============================================



>===============================================
Default suite
Total tests run: 1, Passes: 0, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 0
===============================================

最佳答案

我认为你需要添加一项功能。

capability.setCapability("appWaitActivity", "*");

同时重新检查 APK 路径

关于java - Appium _org.openqa.selenium.SessionNotCreatedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57752851/

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