Component find and not fail

已查看 4 次
跳至第一个未读帖子

OlivierD

未读,
2009年5月2日 12:45:062009/5/2
收件人 easytesting
Hello,

Is there a way to look for a component and not fail if it doesn't
exist.
Basically, I want to look for a Button, if it exist I want to click
on it. If not do nothing.

Thanks in advance,

Olivier

Alex Ruiz

未读,
2009年5月2日 15:15:242009/5/2
收件人 easyt...@googlegroups.com
Hi Olivier,

ComponentFinder has a method 'findAll' that returns a list of components that match search criteria specified in a ComponentMatcher (Monday's release includes an overloaded version that takes a GenericComponentMatcher). If no components were found, the returned list will be empty without throwing exceptions.

Use the method 'finder' in a FEST robot to obtain a ComponentFinder.

Regards,
-Alex

OlivierD

未读,
2009年5月2日 16:35:292009/5/2
收件人 easytesting
Hi Alex,

I am doing
Collection<Component> found = robot.finder().findAll(new
ComponentMatcher() {

public boolean matches(Component c) {
if (c instanceof JButton) {
if(((JButton) c).getName() != null){
if(((JButton) c).getName().compareTo
("MY_BUTTON") == 0){
return true;
}
}
}
return false;
}
});


But when I run the test on xvfb

I got an exceptioin :
Test class should have public zero-argument constructor

java.lang.Exception: Test class should have public zero-argument
constructor
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
Caused by: java.lang.NoSuchMethodException: unit.tests.InventairesTest
$1.()
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)

Thanks,

Olivier

On May 2, 9:15 pm, Alex Ruiz <alex.ruiz...@gmail.com> wrote:
> Hi Olivier,
>
> ComponentFinder has a method 'findAll' that returns a list of components
> that match search criteria specified in a ComponentMatcher (Monday's release
> includes an overloaded version that takes a GenericComponentMatcher). If no
> components were found, the returned list will be empty without throwing
> exceptions.
>
> Use the method 'finder' in a FEST robot to obtain a ComponentFinder.
>
> Regards,
> -Alex
>

Alex Ruiz

未读,
2009年5月4日 09:15:202009/5/4
收件人 easyt...@googlegroups.com
Hi Olivier,

It seems that the problem is that your test case does not have a default constructor.

Cheers,
-Alex
回复全部
回复作者
转发
0 个新帖子