简体   繁体   English

错误:无法初始化主类基引起:java.lang.NoClassDefFoundError:org/openqa/selenium/Capabilities

[英]Error: Unable to initialize main class base Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/Capabilities

I have looked through all the solutions, but all of them are vague.我已经查看了所有解决方案,但所有解决方案都含糊不清。 They just tell to add jar files, but don't specify which ones and from where.他们只是告诉添加 jar 文件,但没有指定哪些以及从何处添加。 The links provided are also very vague.提供的链接也很模糊。 Besides this, another solution was to add jar files to classpath, not module path, but I am unable to find where either of them are located in the configure path option.除此之外,另一个解决方案是将 jar 文件添加到类路径,而不是模块路径,但我无法在配置路径选项中找到它们中的任何一个。 Following is my code:以下是我的代码:

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;

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


public class base {

    public static void main(String[] args) throws MalformedURLException { 
        // TODO Auto-generated method stub
        File f=new File("src");
        File fs=new File(f, "app-debug.apk");
    
        DesiredCapabilities cap=new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus_5X_API_30_2");
        cap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
        cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
        AndroidDriver<AndroidElement> driver=new AndroidDriver<>(new 
        URL("http://127.0.0.1:4723/wd/hub"),cap);

    }

}

Make sure you download the jar official website :确保您下载 jar 官方网站:

https://www.selenium.dev/downloads/ And add it by going to : File>Project structure>Modules>Dependencies and clicking the “+” checkbox to add a new jar file and select the one you downloaded (make sure it is latest version) https://www.selenium.dev/downloads/并通过以下方式添加它:文件>项目结构>模块>依赖项并单击“+”复选框以添加一个新的 jar 文件并选择您下载的那个(确保它是最新版本)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会出现此错误:无法初始化主类 Frst 原因:java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver - why it is giving this Error: Unable to initialize main class Frst Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver 错误:无法初始化主 class 主原因:java.lang.NoClassDefFoundError: [[LInt; - Error: Unable to initialize main class Main Caused by: java.lang.NoClassDefFoundError: [[LInt; 错误:无法初始化主类文件。Main 原因:java.lang.NoClassDefFoundError:Stage - Error: Unable to initialize main class files.Main Caused by: java.lang.NoClassDefFoundError: Stage 错误:无法初始化主类 Car 原因:java.lang.NoClassDefFoundError: string - Error: Unable to initialize main class Car Caused by: java.lang.NoClassDefFoundError: string 错误:无法初始化主 class AirMail 原因:java.lang.NoClassDefFoundError: javax/mail/Authenticator - Error: Unable to initialize main class AirMail Caused by: java.lang.NoClassDefFoundError: javax/mail/Authenticator Java Selenium 错误:线程“main”中的异常 java.lang.NoClassDefFoundError:org/openqa/selenium/HasAuthentication,IntelliJ IDEA - Java Selenium Error: Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/HasAuthentication, IntelliJ IDEA Corda-无法初始化主类胶囊(引起原因:java.lang.NoClassDefFoundError:java / lang / instrument / Instrumentation) - Corda - Unable to initialize main class Capsule (Caused by: java.lang.NoClassDefFoundError: java/lang/instrument/Instrumentation) 无法初始化主类,导致:java.lang.NoClassDefFoundError: com/mashape/unirest/http/exceptions/UnirestException [JAVA] - Unable to initialize main class, Caused by: java.lang.NoClassDefFoundError: com/mashape/unirest/http/exceptions/UnirestException [JAVA] 无法初始化主 class com....,原因:java.lang.NoClassDefFoundError - Unable to initialize main class com...., Caused by: java.lang.NoClassDefFoundError 线程“主”中的异常 java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver - Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM