

スレッド「JavaFX アプリケーション スレッド」java.lang.NoClassDefFoundError での例外: org/openqa/selenium/WebDriver
php小编新一带来的Java问答:在开发JavaFX应用程序时,有时会遇到异常java.lang.NoClassDefFoundError,错误提示为org/openqa/selenium/WebDriver。这个异常通常表示缺少WebDriver类的依赖包,需要在项目中添加相应的依赖以解决该问题。接下来我们将详细介绍如何处理这种异常,并提供解决方案,让您顺利解决线程问题。
问题内容
根据我当前的代码,有什么可能导致此异常的线索吗?
运行以下代码时:
main.java
package application; import java.io.ioexception; import javafx.application.application; import javafx.stage.stage; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.layout.gridpane; public class main extends application { @override public void start(stage primarystage) throws ioexception { button runbutton = new button("run"); runbutton.setonaction(e -> { test test = new test(); }); gridpane gridbox = new gridpane(); gridbox.add(runbutton, 0, 0); scene scene = new scene(gridbox, 380, 150); primarystage.setscene(scene); primarystage.show(); } public static void main(string[] args) { launch(args); } }
测试.java
package application; import org.openqa.selenium.webdriver; import org.openqa.selenium.chrome.chromedriver; public class test { webdriver driver; public static void main(string[] args) { test obj = new test(); obj.setupwebsite(); } public void setupwebsite() { //creates chrome window. driver = new chromedriver(); //sets up window to maximize and go to brink website. driver.manage().window().maximize(); driver.get("https://www.google.com"); } }
我得到的只是以下内容:
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver at application.Main.lambda$0(Main.java:18) at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189) at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at [email protected]/javafx.event.Event.fireEvent(Event.java:198) at [email protected]/javafx.scene.Node.fireEvent(Node.java:8875) at [email protected]/javafx.scene.control.Button.fire(Button.java:203) at [email protected]/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:207) at [email protected]/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274) at [email protected]/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247) at [email protected]/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232) at [email protected]/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189) at [email protected]/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59) at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58) at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at [email protected]/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56) at [email protected]/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114) at [email protected]/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74) at [email protected]/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at [email protected]/javafx.event.Event.fireEvent(Event.java:198) at [email protected]/javafx.scene.Scene$MouseHandler.process(Scene.java:3984) at [email protected]/javafx.scene.Scene.processMouseEvent(Scene.java:1890) at [email protected]/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2708) at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411) at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450) at [email protected]/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424) at [email protected]/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449) at [email protected]/com.sun.glass.ui.View.handleMouseEvent(View.java:551) at [email protected]/com.sun.glass.ui.View.notifyMouse(View.java:937) at [email protected]/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at [email protected]/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:185) at java.base/java.lang.Thread.run(Thread.java:1583) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ... 46 more
我已确认我的所有 jar 文件都位于正确的位置。我可以单独运行 test.java 文件。我有这个代码的更大版本,最初认为这是由于整个代码有问题,但发现即使精简到这个,它仍然会继续。
解决方法
想通了。我必须将所有 JAR 文件添加到运行配置类路径中。
以上がスレッド「JavaFX アプリケーション スレッド」java.lang.NoClassDefFoundError での例外: org/openqa/selenium/WebDriverの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









Python および WebDriver 拡張機能: Web ページでのマウス ホイール操作のシミュレート はじめに: Web インタラクション デザインの継続的な開発に伴い、自動テストにおけるユーザー操作のシミュレートがますます重要になってきています。一部の Web ページでは、マウス ホイールの使用が一般的な操作の 1 つになっています。ただし、Python を使用して自動テスト スクリプトを作成する開発者にとって、WebDriver でマウス ホイール操作をシミュレートする方法が課題になる場合があります。この記事ではPythonとWebDrivを使った方法を紹介します。

Python と WebDriver を使用して Web ページのスクリーンショットを作成し、PDF ファイルとして保存する 概要: Web 開発およびテスト中に、分析、記録、レポート作成のために Web ページのスクリーンショットを作成することが必要になることがよくあります。この記事では、Python と WebDriver を使用して Web ページのスクリーンショットを撮り、そのスクリーンショットを PDF ファイルとして保存して簡単に共有したりアーカイブしたりする方法を紹介します。 1. SeleniumWebDriver をインストールして構成します。 Python をインストールします。 Python 公式 Web サイト (https:

Python と WebDriver を使用して、Web ページに認証コードを自動的に入力します。インターネットの発展に伴い、セキュリティの向上と自動攻撃の防止を目的として、ユーザー登録やログインなどの操作に認証コードの仕組みを導入する Web サイトが増えています。ただし、検証コードを手動で入力するのは面倒なだけでなく、ユーザー エクスペリエンスが複雑になります。では、認証コードを自動的に入力する方法はあるのでしょうか?答えは「はい」です。この記事では、PythonとWebDriverを使ってWebページに認証コードを自動入力する方法を紹介します。まず、私は

Python と WebDriver を使用して Web ページの自動更新を実装する はじめに: 毎日の Web ブラウジングでは、リアルタイム データの監視、動的ページの自動更新など、Web ページの頻繁な更新が必要なシナリオによく遭遇します。 Web ページを手動で更新すると多くの時間とエネルギーが無駄になります。そのため、Python と WebDriver を使用して Web ページを自動的に更新する機能を実装し、作業効率を向上させることができます。 1. インストールと構成環境 開始する前に、対応する環境をインストールして構成する必要があります。 Pythonをインストールする

Python と WebDriver を使用して Web ページ上のフォーム データを自動的に入力することは、ソフトウェア開発プロセスの重要な部分であり、Web フォームの自動入力もその 1 つです。開発者にとって、フォームに手動で入力するのは面倒でエラーが発生しやすいプロセスです。 Python と WebDriver を使用して自動テスト プロセス中にテーブル データを自動的に入力すると、手動での作業の重複が減り、テストの効率が向上します。この記事ではPythonでSeleniumを使う方法を紹介します。

Python および WebDriver 拡張機能: Web ページでの右クリックのマウス クリックをシミュレートする Python と WebDriver を使用して自動 Web ページ テストを行う場合、多くの場合、クリック、ドラッグ、右クリック メニュー操作などのユーザーのマウス動作をシミュレートする必要があります。 WebDriver は、クリック、ドラッグ アンド ドロップなどのいくつかの基本的なマウス アクション関数を提供しますが、マウスの右クリックをシミュレートする関数を直接提供するわけではありません。この記事ではPythonとWebDの使い方を紹介します。

Python と WebDriver の拡張機能を使用して、Web ページのドラッグ アンド ドロップ操作を自動化します。実際の Web アプリケーションでは、ドラッグ アンド ドロップ (ドラッグ アンド ドロップ) は一般的な対話型操作であり、ユーザー エクスペリエンスと利便性を向上させることができます。 Web ページのドラッグ アンド ドロップ操作を自動化することは、テスターにとって重要かつ一般的なタスクです。この記事では、Python と WebDriver 拡張機能を使用して、Web ページ上のドラッグ アンド ドロップ操作を自動化する方法を紹介します。 1. 準備 始める前に、Pyt をインストールする必要があります

Python と WebDriver を使用してフォーム自動入力機能を実装する 日常の Web サイト閲覧では、フォームに入力する必要がある場面に遭遇することがよくあります。同じまたは類似のフォームに頻繁に入力する必要がある場合、手動で入力するのは面倒で時間がかかります。幸いなことに、Python と WebDriver を使用すると、フォームに自動入力する機能を実現し、作業効率を向上させることができます。まず、Selenium ライブラリをインストールする必要があります。 Selenium は、シミュレーションを実行できる自動テスト ツールです。