获取错误:无法访问org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取错误:无法访问org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator。相关的知识,希望对你有一定的参考价值。
我试图通过maven命令运行appium代码,但无法运行。我找了很多地方,但没有找到任何答案。
当以TestNG的方式运行代码时,它可以正常工作。但是,当我尝试使用mvn test运行时,我得到了错误信息。
Utilities.java ( mvn 抛出错误的地方 )
package practise.AppiumFramework;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
public class Utilities {
AndroidDriver<AndroidElement> driver;
public Utilities(AndroidDriver<AndroidElement> driver) {
this.driver = driver;
}
public void scrollToText(String text) {
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(""+text+""));");
}
}
POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>practise</groupId>
<artifactId>AppiumFramework</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AppiumFramework</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<build>
<resources>
<resource>
<directory>src/main/java/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.3.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-6</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0-alpha1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0-alpha1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.1.6</version>
</dependency>
</dependencies>
</project>
如果你们需要更多信息,请告诉我?
日志中出现了错误------------------------------。
Class file for org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator not found
Maven无法加载上述类。请尝试设置
useSystemClassLoader=false
如下图所示<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M4</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin> </plugins> </build>
参考 - https:/maven.apache.orgsurefiremaven-surefire-pluginexamplesclass-loading.html。
以上是关于获取错误:无法访问org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator。的主要内容,如果未能解决你的问题,请参考以下文章
Discord bot 无法访问 Google Sheets 获取错误请求缺少有效的 API 密钥
获取错误:无法访问org.openqa.selenium.virtualauthenticator.HasVirtualAuthenticator。
错误 TS1086 无法在环境上下文中声明访问器。获取 firebaseUiConfig(): NativeFirebaseUIAuthConfig