简体   繁体   English

尝试使用robotframework进行测试时,Swing应用程序未启动

[英]Swing Application not launching when trying to test with robotframework

I am trying to run some automated tests on a swing based java application using the robotframework's swing library. 我正在尝试使用robotframework的swing库在基于swing的java应用程序上运行一些自动化测试。 I think I have got all the libraries installed. 我想我已经安装了所有库。 However, when I run the test it is unable to actually launch the application properly (ie the fail tests), and I am getting whole bunch of warnings(?) before the test actually starts. 但是,当我运行测试时,它实际上无法正确启动应用程序(即失败测试),并且在测试真正开始之前,我会收到很多警告(?)。 Also, I am briefly see the Java icon appear on the dock, but no window actually opens. 另外,我会短暂地看到Java图标出现在扩展坞上,但是实际上没有窗口打开。

I don't have any problem with testing the demo application here though. 在这里测试演示应用程序没有任何问题。 That works fine. 很好

Below is my robot script: 以下是我的机器人脚本:

*** settings ***
Library  SwingLibrary

*** Test Cases ***
Test Push Button
    Start Test Application

*** Keywords ***
Start Test Application
    Start Application  com.xyz.app.ui.MainFrame
    Select Main Window

Here is the output: 这是输出:

    davids$ sudo CLASSPATH=lib/swinglibrary-1.5.1.jar:app.jar jybot app.robot
Password:
10:31:34.578 [MainThread] DEBUG o.p.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
10:31:34.613 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - java.nio.Buffer.address: available
10:31:34.613 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
10:31:34.614 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
10:31:34.615 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
10:31:34.616 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - Java version: 8
10:31:34.616 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.noUnsafe: false
10:31:34.616 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - sun.misc.Unsafe: available
10:31:34.617 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.noJavassist: false
10:31:34.697 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - Javassist: available
10:31:34.698 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T (java.io.tmpdir)
10:31:34.698 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
10:31:34.698 [MainThread] DEBUG o.p.n.u.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
10:31:34.698 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 4
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 4
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
10:31:34.699 [MainThread] DEBUG o.p.n.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
10:31:34.720 [MainThread] DEBUG o.p.n.c.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 8
10:31:34.768 [MainThread] DEBUG o.p.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
10:31:34.768 [MainThread] DEBUG o.p.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
==============================================================================
app                                                                          
==============================================================================
Test Push Button                                                      | FAIL |
com.xyz.app.ui.MainFrame
------------------------------------------------------------------------------
app                                                                   | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output:  /Users/davids/swinglibrary-demo/output.xml
Log:     /Users/davids/swinglibrary-demo/log.html
Report:  /Users/davids/swinglibrary-demo/report.html

Also, I have verified that the app.jar file does in fact contain the path to the MainFrame class: com/xyz/app/ui/MainFrame.class 另外,我已经验证了app.jar文件确实包含MainFrame类的路径:com / xyz / app / ui / MainFrame.class

UPDATE: Using "Start Application In Separate Thread" keyword instead of "Start Application" gives a new error. 更新:使用“在单独的线程中启动应用程序”关键字而不是“启动应用程序”给出了一个新的错误。 It seems that it can't find the main class, even though I have manually confirmed the path of the main class by unzipping the jar file.: 似乎找不到主类,即使我通过解压缩jar文件手动确认了主类的路径也是如此:

Exception in thread "Thread-14" java.lang.RuntimeException: java.lang.ClassNotFoundException: com.xyz.app.ui.MainFrame at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords$1.run(ApplicationLaunchingKeywords.java:53) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: com.xyz.app.ui.MainFrame at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords.getMainMethod(ApplicationLaunchingKeywords.java:64) at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords.launchApplication(ApplicationLaunchingKeywords.java:32) at org.robotframework.swing.keyword.launch.ApplicationLaunchingKeywords$1.run(ApplicationLaunchingKeywords.java:51) ... 1 more

Following solves the issue: 以下解决了这个问题:

  • Setting CLASSPATH using export instead of defining it inline. 使用export设置CLASSPATH而不是内联定义。
  • Using the fullpath to the .jars. 使用.jars的完整路径。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM