appium录制代码运行失败

各位老师,麻烦看一下为什么会报错呢?另,请问怎么看报错信息呢?一遇到这种情况就麻爪~

报错信息如下:

代码如下:

package com.appium;

import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

public class SampleTest {

private static AndroidDriver driver;

@BeforeAll
public static void setUp() throws MalformedURLException {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("platformName", "Android");
    desiredCapabilities.setCapability("appium:platformVersion", "6.0");
    desiredCapabilities.setCapability("appium:deviceName", "127.0.0.1:7555");
    desiredCapabilities.setCapability("appium:automationName", "UiAutomator2");
    desiredCapabilities.setCapability("appium:appActivity", ".MainActivity");
    desiredCapabilities.setCapability("appium:appPackage", "io.cloudgrey.the_app");
    desiredCapabilities.setCapability("appium:ensureWebviewsHavePages", true);
    desiredCapabilities.setCapability("appium:nativeWebScreenshot", true);
    desiredCapabilities.setCapability("appium:newCommandTimeout", 3600);
    desiredCapabilities.setCapability("appium:connectHardwareKeyboard", true);

    URL remoteUrl = new URL("http://127.0.0.1:4723/wd/hub");

    driver = new AndroidDriver(remoteUrl, desiredCapabilities);
}

@Test
public void sampleTest() {
    WebElement el1 = (WebElement) driver.findElement(By.xpath("//android.view.ViewGroup[@content-desc=\"Echo Box\"]/android.widget.TextView[1]"));
    el1.click();
    WebElement el2 = (WebElement) driver.findElement(By.id("messageInput"));
    el2.sendKeys("Hello World !");
    WebElement el3 = (WebElement) driver.findElement(By.xpath("//android.view.ViewGroup[@content-desc=\"messageSaveBtn\"]/android.widget.TextView"));
    el3.click();
    WebElement el4 = (WebElement) driver.findElement(By.xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ImageButton"));
    el4.click();
    List<WebElement> els1 =  driver.findElements(By.cssSelector(".android.widget.ImageButton"));
}

@AfterAll
public static void tearDown() {
    driver.quit();
}

}

"appium:platformName" 使用这个key来替代你之前写的 “platformName” 或者把它删掉也行

添加为appium:platformName,也还是报那个问题

我偿试修改了一下依赖的版本,java-client从8.0调整为8.1之后,就不那个问题了~

感谢老师的回复~