Urgent:[Unable to Locate JPanel Hierarchy if multiple child components present in parent without name property]

26 views
Skip to first unread message

Arun K

unread,
Apr 28, 2015, 8:19:44 AM4/28/15
to windowte...@googlegroups.com, senthil...@gmail.com




As shown in the above pic. I am able to locate the "Panel4" with below code.

IWidgetLocator locator = (IWidgetLocator) ui
.find(new SwingWidgetLocator(JPanel.class, "Panel4", 0,
new NamedWidgetLocator("Panel3")));
But, 

If remove the Panel4( name) from the above code, its throws WidgetNotFoundException exception. I guess it should find the component based on the index. This exception is thrown only if parent has more than one child components(JPanel in this case) without name.

In my application most of the Panels don't have the name property. Is there any workaround available for this. ?


Regards,
Arun Kumar K.

Fred G

unread,
Apr 28, 2015, 10:14:12 AM4/28/15
to windowte...@googlegroups.com, senthil...@gmail.com
The widget must be described in an unambiguous way, either by it's hierarchy or by something like a NamedWidgetLocator.

You can specify an index for a locator:

This should find the first widget:      IWidgetLocator locator1 = (IWidgetLocator) ui.find(new SwingWidgetLocator(JLovTextField.class, 0, new SwingWidgetLocator(JPanel.class, "Panel4", 0, new NamedWidgetLocator("Panel3"))));
This should find the second widget: IWidgetLocator locator2 = (IWidgetLocator) ui.find(new SwingWidgetLocator(JLovTextField.class, 1, new SwingWidgetLocator(JPanel.class, "Panel4", 0, new NamedWidgetLocator("Panel3"))));

Arun and Senthil: Please do not open any more topics dealing with the same basic problem (WidgetNotFoundException).

Arun K

unread,
Apr 28, 2015, 3:55:12 PM4/28/15
to windowte...@googlegroups.com, senthil...@gmail.com

Dear Fred,

Thank you for the reply.


As shown above the Panels don't have name. 

When i try to locate the JLovTextField.class in the second panel I am getting WidgetNotFoundException.
As marked below code, the index should be 1 or 7?. I have tried both, but still same error.

IWidgetLocator locator2 = (IWidgetLocator) ui
.find(new SwingWidgetLocator(JLovTextField.class, 0,
new SwingWidgetLocator(JPanel.class, 1,
new NamedWidgetLocator("Panel3"))));



I am able to select the JCheckBox from panel 1: (B'coz it has text)

IWidgetLocator locator2 = (IWidgetLocator) ui
.find(new SwingWidgetLocator(JCheckBox.class,"E-SLI Data",
new SwingWidgetLocator(JPanel.class, 0,
new NamedWidgetLocator("Panel3"))));

I am not able to select the JLovTextField from panel 1: (Widget don't have Text)

IWidgetLocator locator2 = (IWidgetLocator) ui
.find(new SwingWidgetLocator(JLovTextField.class,
new SwingWidgetLocator(JPanel.class, 0,
new NamedWidgetLocator("Panel3"))));


Am i missing anything ?. Please advise.


Regards,
Arun Kumar K.

Arun K

unread,
Apr 28, 2015, 11:53:37 PM4/28/15
to windowte...@googlegroups.com, senthil...@gmail.com
Dear Fred,

I am not able to find the panel 1  and panel 2 with code also.


IWidgetLocator panel1Locator= (IWidgetLocator) ui
.find(new SwingWidgetLocator(JPanel.class, 0,
new NamedWidgetLocator("Panel3")));

System.out.println("panel1Locator ::" + panel1Locator);


IWidgetLocator panel2Locator= (IWidgetLocator) ui
.find(new SwingWidgetLocator(JPanel.class, 1,
new NamedWidgetLocator("Panel3")));

System.out.println("panel2Locator ::" + panel2Locator);

Note: As I mentioned , Child panels in "Panel3" dont have any name. That's the reason am giving only index here. I think above code is working if i have names forchild components.


It would be a great help if you could provide your inputs on this.
Regards,
Arun Kumar K.

Venkata Prasad Reddy

unread,
Dec 16, 2015, 6:15:35 AM12/16/15
to windowtester-pro, senthil...@gmail.com
Hi,

I am able to Record and Play ContactManagerRPC Application which is provided by Window Tester Pro Team, but I dont know the steps for Recording and Playing my own Java Swing Application.

Please tell me, Steps for Recording and Playing Application (Not provided by Window Tester Pro Team).

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages