I'm currently rewriting some of our test methods from WT 3.8 to WT 6.0.
It seems that click method on SWT locators uses a new SWTWidgetReference class, which implements IWidgetLocator, instead of the old one which extends in addition SWTWidgetLocator.
The hierarchy tree :
- Code: Select all
-> IWidgetLocator
-> SWTWidgetLocator
-> com.windowtester.runtime.swt.locator.SWTWidgetReference (the old one, inner class of SWTWidgetLocator)
-> IWidgetReference
->ISWTWidgetReference
-> com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference (the new one)
For my needs, I use the findAll method (returning IWidgetLocator[]) to get every locators of a given class and i filter this list.
The IWidgetLocator of interest is then adapted using the following method to get a usable SWTWidgetLocator : SWTWidgetLocator.adapt().
The SWTWidgetLocator is needed if the locator is used as a parent in another locator.
In WT 6.0 this method seems obsolete since it returns a SWTWidgetReference (old version) which is no longer clickable (return a ClassCastException, WT try to cast it with the new class)
- Code: Select all
public static SWTWidgetLocator adapt(IWidgetLocator parent)
{
if(parent instanceof IWidgetReference)
return new SWTWidgetReference((IWidgetReference)parent); //the old one : an inner class of SWTWidgetLocator
if(parent instanceof SWTWidgetLocator)
return (SWTWidgetLocator)parent;
else
return null;
}
I have the solution to use directly the IWidgetLocator without adapting it.
It's usable in click method, but not as a parent in a SWTWidgetLocator. The new reference can't be casted in a SWTWidgetLocator, since it no longer extends it.
Do you have an idea on how can i use a SWTWidgetReference as a parent in a SWTWidgetLocator ?
Josselin