java.lang.NoClassDefFoundError: org/openqa/selenium/remote/internal/JsonToWebElementConverter
java项目启动报上述错误
原因是版本问题
<!-- Appium Java Client 依赖 -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.6.0</version>
</dependency>
如果版本过高
<!-- Appium Java Client 依赖 -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.5.1</version>
</dependency>
则会报
java.lang.IllegalAccessError: tried to access method org.openqa.selenium.remote.http.ClientConfig.(Ljava/net/URI;Ljava/time/Duration;Ljava/time/Duration;Lorg/openqa/selenium/remote/http/Filter;Ljava/net/Proxy;Lorg/openqa/selenium/Credentials;)V from class io.appium.java_client.AppiumClientConfig
java.lang.IllegalAccessError: tried to access method org.openqa.selenium.remote.http.ClientConfig.<init>(Ljava/net/URI;Ljava/time/Duration;Ljava/time/Duration;Lorg/openqa/selenium/remote/http/Filter;Ljava/net/Proxy;Lorg/openqa/selenium/Credentials;)V from class io.appium.java_client.AppiumClientConfig
那么我们解决这种appium的问题的时候,就可以在两种报错中间缩小范围找对应的版本,
使用8.1.0
在使用8.0.0,每次使用需要clear install
<!-- Appium Java Client 依赖 -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.0.0</version>
</dependency>
再次运行,运行成功
appium对应的selenium
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium - java</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>appium - java - client</artifactId>
<version>8.0.0</version>
</dependency>