Is it possible to test Java applets with Robot framework?
When running the test with Java applet the following error message
is shown "Current context is null. Please select a context".
Test works fine with Java application but I would need to use Robot
framework with Java applets.
I have a Java applet
public class ButtonDemo extends JApplet
implements ActionListener {
...
public void init() {
setName("paa");
...
panel.setName("paa");
and html file (testi.html) for the applet
<applet
name="paa"
archive="."
code="ButtonDemo.class"
...
and Robot framework test file
...
<tr>
<td class="col_name">Library</td>
<td class="col_value">SwingLibrary</td>
<td class="col_value"></td>
<td class="col_value"></td>
</tr>
...
<tr>
<td class="col_name">Launch Registration Application</td>
<td class="col_value">Start Application</td>
<td class="col_value">sun.applet.AppletViewer</td>
<td class="col_value">-Xnosecurity</td>
<td class="col_value">testi.html</td>
<td class="col_value"></td>
</tr>
...
<tr>
<td class="col_name">Testi0</td>
<td class="col_value">Select Context</td>
<td class="col_value">paa</td>
</tr>
...
when running the test the following error message is shown
Testi0 |
FAIL |
Current context is null. Please select a context.
------------------------------------------------------------------------------
Example 2 |
FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
==============================================================================
+ START SUITE: Example 2 [ ]
==============================================================================
+- START SETUP: Launch Registration Application [ ]
+-- START KW: SwingLibrary.Start Application [ sun.applet.AppletViewer |
-Xnosecurity | testi.html ]
Warning: disabling security.
+-- END KW: SwingLibrary.Start Application (00:00:01.781)
+- END SETUP: Launch Registration Application (00:00:02.366)
------------------------------------------------------------------------------
+- START TEST: Testi0 [ ]
------------------------------------------------------------------------------
+-- START KW: Testi0 [ ]
+--- START KW: SwingLibrary.Select Context [ paa ]
Current context is null. Please select a context.
java.lang.RuntimeException:
at
org.robotframework.javalib.library.AnnotationLibrary.retrieveInnerException(AnnotationLibrary.java:93)
at
org.robotframework.javalib.library.AnnotationLibrary.runKeyword(AnnotationLibrary.java:75)
at SwingLibrary.runKeyword(SwingLibrary.java:46)
Caused by: java.lang.IllegalStateException: Current context is null.
Please select a context.
Br
R
On Tue, Apr 7, 2009 at 11:39 AM, Roni Hursti <rshu...@cc.hut.fi> wrote:
> When running the test with Java applet the following error message
> is shown "Current context is null. Please select a context".
> Test works fine with Java application but I would need to use Robot
> framework with Java applets.
The keyword "Select Context" is poorly documented (this will be fixed
in the next release).
It actually requires that a "parent context" has been selected before.
It is used only to refine the current context where SwingLibrary
starts looking for the components to operate on. In other words you
have to use "Select Dialog" or "Select Window" keyword before you can
use "Select Context".
This is where SwingLibrary has some limitations when it comes to
testing applets. Because applets are neither dialogs nor windows
(JFrames) those abovementioned keywords cannot (at the present time)
select the required parent context.
> Is it possible to test Java applets with Robot framework?
Yes. But first you'll need a new keyword that can select the context
with applets or to modify the existing ones so that they can do it.
You can:
1) Create an issue at
http://code.google.com/p/robotframework-swinglibrary/issues/list
2) Make one yourself. For this I suggest you read these:
- http://jemmy.netbeans.org/applets.html (SwingLibrary uses Jemmy internally)
- http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#creating-test-libraries
I think the solution 1 is better as this is in my opinion a keyword
others might want to use too. Unfortunately it wont be possible to do
include the modification to today's release.
We try to do a new release once or twice a month.
Best regards,
Heikki