我需要对java swing应用程序进行自动化测试。我正在 python 中使用带有机器人框架的remoteswinglibrary。我正在使用 Pycharm IDE。我的 python 版本是 3.12.1 。我下载了remoteswinglibrary-2.3.2 jar,并添加到pycharm中的项目结构中。我还在环境变量中添加了该 jar 作为 PYTHONPATH (这是之前在 stackoverflow 中推荐的)。但我无法启动该应用程序。
我导入的库如下。
*** 设置*** 库 RemoteSwingLibrary
我的文件类型是 .JNLP 我需要使用 javaws myfile.jnlp 命令启动它。我如何在 pycharm 中使用 python 启动这个应用程序。我本地没有源代码。现在我使用 path/to/my/file javaws myfile.jnlp 在命令行中启动应用程序。我如何在 python + 机器人框架中启动该应用程序以在 python 中实现自动化。
之前我尝试启动一个 jar 文件,如下所示。
*** 测试用例 *** 启动程序 启动应用程序 java -jar myjar
我使用 robots loginTest.robot 命令运行它。我遇到了以下错误。但该关键字存在于库中。代码中没有错误。运行代码时,出现以下错误。
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\RemoteSwingLibrary.py:284: SyntaxWarning: invalid escape sequence '\$'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\RemoteSwingLibrary.py:286: SyntaxWarning: invalid escape sequence '\$'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\RemoteSwingLibrary.py:284: SyntaxWarning: invalid escape sequence '\$'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\RemoteSwingLibrary.py:286: SyntaxWarning: invalid escape sequence '\$'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:233: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:240: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:252: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:358: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:388: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:390: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:391: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:392: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:394: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:395: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:396: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:405: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:233: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:240: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:252: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:358: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:388: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:390: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:391: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:392: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:394: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:395: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:396: SyntaxWarning: invalid escape sequence '\`'
C:\Users\padmeshp\Downloads\remoteswinglibrary-2.3.2.jar\swinglibrary.py:405: SyntaxWarning: invalid escape sequence '\`'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'system_exit' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'start_application' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'application_started' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'switch_to_application' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'ensure_application_should_close' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'log_java_system_properties' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'set_java_tool_options' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
[ ERROR ] Error in library 'RemoteSwingLibrary': Adding keyword 'reinitiate' failed: Calling dynamic method 'get_keyword_arguments' failed: AttributeError: module 'inspect' has no attribute 'getargspec'
==============================================================================
loginTest
==============================================================================
Launch Application | FAIL |
No keyword with name 'start application' found.
请告诉我我在设置此环境时是否执行了错误的步骤。
[注意:使用remoteswinglibrary可以吗,否则请建议任何其他用于测试java swing应用程序的最佳自动化工具。]
您可能面临一些问题:
您可以尝试使用 Cygwin 进行设置,或者尝试在 PowerShell(较新版本,类似 Linux)中进行设置。 您应该尝试的第一件事是运行remotelibrary.jar 以查看它是否运行正常。可能包括一些演示。或者,您可以尝试运行 SwingLibrary jar 应用程序。