简体   繁体   中英

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. 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.

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

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.:

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.
  • Using the fullpath to the .jars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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