RED Robot Framework Editor - Unexpected error: NoClassDefFoundError: com/github/markusbernhardt/selenium2library/utils/WebDriverCache
RED Robot Framework Editor - Unexpected error: NoClassDefFoundError: com/github/markusbernhardt/selenium2library/utils/WebDriverCache
我在 Java 中使用 RED 机器人框架编辑器。虽然我已经添加了包含的jar文件
'com/github/markusbernhardt/selenium2library/utils/WebDriverCache',错误为 "NoClassDefFoundError"
我使用 robotframework-selenium2library-java-1.4.0.8 创建 java 库。
下面是在 RED 编辑器中生成的控制台命令。
Command: C:\jython2.7.0\bin\jython.exe -J-Dpython.path=C:\jython2.7.0\Lib\site-packages -J-cp .;C:\Java\JarsKCC\Misc.jar;C:\Java\JarsKCC\KCCUtils.jar;C:\Java\JarsKCC\GetElementList.jar;C:\jython2.7.0\selenium-server-standalone-3.3.1.jar;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8 -m robot.run -P C:\jython2.7.0\Lib\site-packages\Selenium2Library --listener C:\Users\CON_RT~1\AppData\Local\Temp\RobotTempDir2533122362618779828\TestRunnerAgent.py:56178:False -s KCC_Automation.TestSuites.TestSeparateWebdriverInstance C:\Java\Workspace\KCC_Automation
Suite Executor: Robot Framework 3.0.2 (Jython 2.7.0 on java1.8.0_121)
执行时收到错误,
[ ERROR ] Unexpected error: NoClassDefFoundError:
com/github/markusbernhardt/selenium2library/utils/WebDriverCache
java.lang.NoClassDefFoundError:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at robot.utils.importer$py.import_(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:274)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py._import_class_or_module(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:77)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py.import_class_or_module(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:74)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.model.visitor$py.visit_suite(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.utils.application$py._execute(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:94)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at robot.utils.application$py.execute_cli(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:49)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at runpy$py._run_code(C:\jython2.7.0\Lib\runpy.py:73)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
at runpy$py._run_module_as_main(C:\jython2.7.0\Lib\runpy.py:161)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
Caused by: java.lang.ClassNotFoundException:
com.github.markusbernhardt.selenium2library.utils.WebDriverCache
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 190 more
Java 我使用的代码 blog
注意:我也用依赖jar文件验证过'robotframework-selenium2library-java-1.4.0.8-jar-with-dependencies'。我仍然面临同样的问题。
'blog' / Whosebug post 中的示例存在一些问题,关键是 class 的名称已更改,因为答案写在 SO 上。但是,当我编译jar文件并将jar文件添加到red.xml
none的class路径部分时,遇到了问题中提到的错误。由于提到的SO问题有两种方法,我都尝试了。
在我看来,您指定的是目录而不是 robotframework-selenium2library-java-1.4.0.8
的 jar 文件。
C:\jython2.7.0\bin\jython.exe
-J-Dpython.path=C:\jython2.7.0\Lib\site-packages
-J-cp .
;C:\Java\JarsKCC\Misc.jar
;C:\Java\JarsKCC\KCCUtils.jar
;C:\Java\JarsKCC\GetElementList.jar
;C:\jython2.7.0\selenium-server-standalone-3.3.1.jar
;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8
-m robot.run
-P C:\jython2.7.0\Lib\site-packages\Selenium2Library
--listener C:\Users\CON_RT~1\AppData\ ... \TestRunnerAgent.py:56178:False
-s KCC_Automation.TestSuites.TestSeparateWebdriverInstance
C:\Java\Workspace\KCC_Automation
所以我的建议是更改它,以便 classpath 反映 jar 文件:
;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8\some-jar-name.jar
我在 Java 中使用 RED 机器人框架编辑器。虽然我已经添加了包含的jar文件 'com/github/markusbernhardt/selenium2library/utils/WebDriverCache',错误为 "NoClassDefFoundError"
我使用 robotframework-selenium2library-java-1.4.0.8 创建 java 库。
下面是在 RED 编辑器中生成的控制台命令。
Command: C:\jython2.7.0\bin\jython.exe -J-Dpython.path=C:\jython2.7.0\Lib\site-packages -J-cp .;C:\Java\JarsKCC\Misc.jar;C:\Java\JarsKCC\KCCUtils.jar;C:\Java\JarsKCC\GetElementList.jar;C:\jython2.7.0\selenium-server-standalone-3.3.1.jar;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8 -m robot.run -P C:\jython2.7.0\Lib\site-packages\Selenium2Library --listener C:\Users\CON_RT~1\AppData\Local\Temp\RobotTempDir2533122362618779828\TestRunnerAgent.py:56178:False -s KCC_Automation.TestSuites.TestSeparateWebdriverInstance C:\Java\Workspace\KCC_Automation
Suite Executor: Robot Framework 3.0.2 (Jython 2.7.0 on java1.8.0_121)
执行时收到错误,
[ ERROR ] Unexpected error: NoClassDefFoundError:
com/github/markusbernhardt/selenium2library/utils/WebDriverCache
java.lang.NoClassDefFoundError:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at robot.utils.importer$py.import_(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:274)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py._import_class_or_module(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:77)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py.import_class_or_module(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:74)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.model.visitor$py.visit_suite(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.utils.application$py._execute(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:94)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at robot.utils.application$py.execute_cli(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:49)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at runpy$py._run_code(C:\jython2.7.0\Lib\runpy.py:73)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
at runpy$py._run_module_as_main(C:\jython2.7.0\Lib\runpy.py:161)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
Caused by: java.lang.ClassNotFoundException:
com.github.markusbernhardt.selenium2library.utils.WebDriverCache
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 190 more
Java 我使用的代码 blog
注意:我也用依赖jar文件验证过'robotframework-selenium2library-java-1.4.0.8-jar-with-dependencies'。我仍然面临同样的问题。
'blog' / Whosebug post 中的示例存在一些问题,关键是 class 的名称已更改,因为答案写在 SO 上。但是,当我编译jar文件并将jar文件添加到red.xml
none的class路径部分时,遇到了问题中提到的错误。由于提到的SO问题有两种方法,我都尝试了。
在我看来,您指定的是目录而不是 robotframework-selenium2library-java-1.4.0.8
的 jar 文件。
C:\jython2.7.0\bin\jython.exe
-J-Dpython.path=C:\jython2.7.0\Lib\site-packages
-J-cp .
;C:\Java\JarsKCC\Misc.jar
;C:\Java\JarsKCC\KCCUtils.jar
;C:\Java\JarsKCC\GetElementList.jar
;C:\jython2.7.0\selenium-server-standalone-3.3.1.jar
;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8
-m robot.run
-P C:\jython2.7.0\Lib\site-packages\Selenium2Library
--listener C:\Users\CON_RT~1\AppData\ ... \TestRunnerAgent.py:56178:False
-s KCC_Automation.TestSuites.TestSeparateWebdriverInstance
C:\Java\Workspace\KCC_Automation
所以我的建议是更改它,以便 classpath 反映 jar 文件:
;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8\some-jar-name.jar