|
Re: How to enable checkbox? [message #1754436 is a reply to message #1754325] |
Fri, 17 February 2017 19:44 |
Patrick Tasse Messages: 85 Registered: July 2009 |
Member |
|
|
Hi Horst,
There's no way to force a widget to be enabled, as there is no UI equivalent to this operation. You should use the application's normal method to enable the widget, such as clicking the "new person" tool bar button in your application.
When you call SWTBotCheckBox.click(), it waits for the button to be enabled.
The default timeout is 5000 ms, but you can change it by modifying the value of the SWTBotPreferences.TIMEOUT public field.
Calling bot.wait(long) is something completely different, it is a method of Java's Object class, it's related to thread synchronization.
Assuming your timeout is long enough, are you sure that your are trying to click the right checkbox button? Calling bot.checkBox() will return the first checkbox button that it finds in the current active shell. Perhaps you need a more specific method to find the widget? Or are there multiple shells or views in your application, and you might need to get a specific bot from the shell or view that contains your checkbox button?
Hope this helps,
Patrick
|
|
|
|
Re: How to enable checkbox? [message #1754598 is a reply to message #1754555] |
Mon, 20 February 2017 16:53 |
Patrick Tasse Messages: 85 Registered: July 2009 |
Member |
|
|
Hi Horst,
Of course we don't want the tester to need to manually click anything while the test is running... I meant that you should use SWTBot API to do the mouse or keyboard actions necessary to enable a widget, because there's no SWTBot API for widget.setEnabled(true).
I'm confused, do you have an issue with the "new person" tool bar button being disabled? I thought clicking that tool bar button was OK, but after clicking it, it was the other checkbox button that was disabled.
If you look at the application when the test is running, does the checkbox button ever become enabled? If it does not, then it could be that the "new person" tool bar button was not properly clicked, or that your application was not in a state ready to handle that button?
Another issue we have seen sometimes is that a lot of widget actions in SWTBot use the sequence FocusIn, Activate, *do stuff*, Deactivate, FocusOut. This is not necessarily representative of the real UI behavior, since clicking a widget doesn't make it lose focus (on the contrary!). While in most cases this doesn't cause a problem, if your application is specifically listening and acting on the FocusOut event, it could interfere.
Patrick
|
|
|
Re: How to enable checkbox? [message #1754655 is a reply to message #1754325] |
Tue, 21 February 2017 10:39 |
Horst Weigelt Messages: 4 Registered: February 2017 Location: Tübingen |
Junior Member |
|
|
solved!
actually I found the solution here in the forum
https://www.eclipse.org/forums/index.php/t/1067419/
Hello Patrick,
thank you for the quick reply!
We probably found out the reason why the click() fails.
The AUT is an E4 application and the containing MPart of the toolButtonWithTooltip("new person") does not have focus and the handler call fails.
This will lead to a chain of Exceptions. I did not see these exceptions last week.
So you are right the application is not in the correct state to handle the click-event.
But we have no solution yet.
Now we are looking for a connection beetween SWT, SWTBot and E4-Parts - without leading to Invalid thread access violations which occur when climbing up the widget tree ....
Do you have an ideas or heard of a similar problem?
Horst
[Updated on: Tue, 21 February 2017 11:20] Report message to a moderator
|
|
|
Re: How to enable checkbox? [message #1754706 is a reply to message #1754655] |
Tue, 21 February 2017 17:01 |
Patrick Tasse Messages: 85 Registered: July 2009 |
Member |
|
|
Hi Horst,
Great that you have solved your problem.
However, without spending too much time, I would have thought that there would be a SWTBot way to give focus to the E4 MPart?
One thing I notice is that SWTBotToolbarButton in particular, does not send a SWT.FocusIn event when click() is called, unlike I mentioned in my last message. Would that have been enough? Then maybe you could call SWTBotToolBarButton.setFocus() before the click(). Or maybe calling active() or setFocus() on the Shell that contains the tool bar?
Otherwise, if I could debug this, I would try to find the point where the E4 MPart gets focus, add a breakpoint there, then manually click the tool bar button, identify in the call stack which SWT event leads to the activation of the MPart, and then see how SWTBot can also trigger that same event...
Patrick
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03449 seconds