Hi, I am new to SWTBot and like it a lot. Thanks for a great product!
Has anyone experience with running SWTBot testsuites under a virtual
framebuffer (Xvfb)? Some of my tests do not work under Xvfb and I do not
know why. I get e lot of "Could not find widget" errors. When I run the
suite with a "real" X11 system all widgets are found.
Another issue with the virtual framebuffer is that
SWTUtils.captureScreenshot() doesn't seem to work. It just creates a
white (empty) image.
I've not tried using Xvfb for running swtbot tests yet.
All our tests run in a proper login shell (we use gnome) and that seems
to work well for us.
I think the errors are primarily because xvfb does not have a proper
window manager, try running gnome in the xvfb session and things should
work fine.
On 04/09/09 2:49 PM, Peter Kullmann wrote:
> Hi, I am new to SWTBot and like it a lot. Thanks for a great product!
>
> Has anyone experience with running SWTBot testsuites under a virtual
> framebuffer (Xvfb)? Some of my tests do not work under Xvfb and I do not
> know why. I get e lot of "Could not find widget" errors. When I run the
> suite with a "real" X11 system all widgets are found.
>
> Another issue with the virtual framebuffer is that
> SWTUtils.captureScreenshot() doesn't seem to work. It just creates a
> white (empty) image.
>
> Thanks for any tips
> Peter
thanks for the ideas. I made some more tests and noticed two things:
1. Screeshots do in fact work in the Xvfb setting - don't know what was
wrong last week...
2. The problem with the "could not find widget" errors seems related to
the fact that Display.getActiveShell() returns null in Xvfb whereas this
is non-null in an interactive setting.
I tried to activate the shell but it doesn't help:
@Test
public void testGetActiveShell() throws Exception {
final Display display = PlatformUI.getWorkbench().getDisplay();
UIThreadRunnable.syncExec(new VoidResult() {
public void run() {
display.getShells()[0].setActive();
}
});
Shell activeShell = UIThreadRunnable.syncExec(display,
new WidgetResult<Shell>() {
public Shell run() {
log.debug("BBB1: display has #of shells: "
+ display.getShells().length);
return display.getActiveShell();
}
});
assertNotNull(activeShell); // fails on Xvfb
}
Regards,
Peter
Ketan Padegaonkar schrieb:
> Hi Peter,
>
> I've not tried using Xvfb for running swtbot tests yet.
>
> All our tests run in a proper login shell (we use gnome) and that seems
> to work well for us.
>
> I think the errors are primarily because xvfb does not have a proper
> window manager, try running gnome in the xvfb session and things should
> work fine.
>
On 07/09/09 5:23 PM, Peter Kullmann wrote:
> Hi Ketan,
>
> thanks for the ideas. I made some more tests and noticed two things:
> 1. Screeshots do in fact work in the Xvfb setting - don't know what was
> wrong last week...
> 2. The problem with the "could not find widget" errors seems related to
> the fact that Display.getActiveShell() returns null in Xvfb whereas this
> is non-null in an interactive setting.
>
> I tried to activate the shell but it doesn't help:
I've noticed this as well. I *think* this happened to me because the
shell did not actually have a proper "window" with a border, title bar
etc, and *apparently* it's not possible to get the title because it does
not have a title bar.
Just an educated guess based on an observation. I may be completely off
on a tangent.
Now, I think I have found a solution: Shell.forceActive() helps. In my
RCP tests I will use something like this:
@Before
public void setUp() throws Exception {
UIThreadRunnable.syncExec(new VoidResult() {
public void run() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShel l()
.forceActive();
}
});
}
Ketan Padegaonkar schrieb:
> On 07/09/09 5:23 PM, Peter Kullmann wrote:
>> Hi Ketan,
>>
>> thanks for the ideas. I made some more tests and noticed two things:
>> 1. Screeshots do in fact work in the Xvfb setting - don't know what was
>> wrong last week...
>> 2. The problem with the "could not find widget" errors seems related to
>> the fact that Display.getActiveShell() returns null in Xvfb whereas this
>> is non-null in an interactive setting.
>>
>> I tried to activate the shell but it doesn't help:
>
> I've noticed this as well. I *think* this happened to me because the
> shell did not actually have a proper "window" with a border, title bar
> etc, and *apparently* it's not possible to get the title because it does
> not have a title bar.
>
> Just an educated guess based on an observation. I may be completely off
> on a tangent.
>