Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » How to decrease warning message such as Widget is not enabled
How to decrease warning message such as Widget is not enabled [message #1800950] Thu, 10 January 2019 09:50 Go to next message
Didier Vojtisek is currently offline Didier VojtisekFriend
Messages: 31
Registered: July 2009
Member
Hi,
in my test suites I have actions such as *
bot.menu("File").menu("New").menu("GEMOC Melange Project for Sequential xDSML").click();
bot.text().setText(PROJECT_NAME);
bot.button("Next >").click();

which was actually generated from the recorder. (in the above code this a kind of "New project" wizard)


However, when running the test I get warning messages such as:
361587 [main] WARN  org.eclipse.swtbot.swt.finder.widgets.SWTBotButton  - Widget is not enabled: (of type 'Button' and with mnemonic 'Next >' and with style 'SWT.PUSH')





What does it really mean? (the test passes correctly ...)
(My guess is that the button takes some time to be enabled and swtbot report it and at some point, the button is enabled and the action is done ?)

How can I decrease the number of such warnings? (My build + test log is quite long and I wish to reduce warnings to significant ones)

[Updated on: Thu, 10 January 2019 09:51]

Report message to a moderator

Re: How to decrease warning message such as Widget is not enabled [message #1800986 is a reply to message #1800950] Thu, 10 January 2019 16:46 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 84
Registered: July 2009
Member
Hi Didier,

The warnings are created by the calls to notify(). In the implementation of SWTBotButton.click():

		waitForEnabled();
		notify(SWT.MouseEnter);
		notify(SWT.MouseMove);
		notify(SWT.Activate);
		notify(SWT.FocusIn);
		notify(SWT.MouseDown);
		notify(SWT.MouseUp);
		notify(SWT.Selection);
		notify(SWT.MouseHover);
		notify(SWT.MouseMove);
		notify(SWT.MouseExit);
		notify(SWT.Deactivate);
		notify(SWT.FocusOut);


As soon as the SWT.Selection event is sent, the application receives this and acts on it, which disables the button or even perhaps disposes it. Then the remaining 5 events are not sent and the warning is logged instead.

The difference is that if the widget was disposed (for example the dialog that contains an "OK" button is closed), SWTBot uses log.trace(), while if the widget is not disposed but not enabled SWTBot uses log.warn(). By default log.trace() does not appear in the logs, but log.warn() does.

Perhaps the easiest solution would be to change SWTBot to use log.trace() for that specific message. Then it won't show up by default in the logs.

But I'd like to also verify first if the real SWT sends the events or not when the button becomes not enabled due to it being clicked.

Patrick

[Updated on: Thu, 10 January 2019 18:22]

Report message to a moderator

Re: How to decrease warning message such as Widget is not enabled [message #1800995 is a reply to message #1800986] Thu, 10 January 2019 19:19 Go to previous messageGo to next message
Patrick Tasse is currently offline Patrick TasseFriend
Messages: 84
Registered: July 2009
Member
So I tested a similar scenario (clicking Next button in a wizard that deactivates the button in the next wizard page). The events however were not sent in the same order as the SWTBot code:

SWT.MouseEnter
SWT.MouseMove
SWT.MouseDown
SWT.Activate
SWT.FocusIn
SWT.MouseUp
SWT.Selection
SWT.FocusOut
SWT.Deactivate
SWT.MouseExit


The last 3 events I would assume to be sent by the application code interacting with SWT (when handling the button selection), so it's probably OK if SWTBot doesn't send them again.

Interestingly, after the Button gets disabled, the subsequent mouse events are sent by the underlying parent Composite (even when the mouse is over the disabled Button). It's like the Button doesn't exist for SWT. This seems to indicate that it's correct for SWTBot not to send events from disabled widgets.

Patrick
Re: How to decrease warning message such as Widget is not enabled [message #1801000 is a reply to message #1800995] Thu, 10 January 2019 20:44 Go to previous message
Didier Vojtisek is currently offline Didier VojtisekFriend
Messages: 31
Registered: July 2009
Member
You're right about the click()
I have a similar message when calling this kind of code (sorry it's in xtend and not in java)
def void clickOnStepInto(){
		val matcher = allOf(widgetOfType(typeof(ToolItem)), 
			anyOf(withTooltip("Step &Into (F5)"), withTooltip("Step &Into")), 
			withStyle(SWT.PUSH, "SWT.PUSH")
		)
		val btn = new SWTBotToolbarPushButton( bot.widget(matcher, 0) as ToolItem, matcher);
		btn.click
}


And I know that the Step button (the one used for debug :-) ) may be disabled and then enabled later during execution.

Is there a way to write a query that waits for the button to be enabled?

Maybe the SWTBOTButton. click() should be implemented in a way where it waits by default and fails only if the button is never enabled. It should probably fail and not just report a warning in this case. (I know that extensive tests should also test clicking on disabled buttons but in most situations, we try to mimic "normal" user behavior)
Previous Topic:bot().textWithLabel() does not found appropriated text field
Next Topic:SWTBot and WebStart how to add test plugin to application
Goto Forum:
  


Current Time: Fri Apr 19 23:09:50 GMT 2024

Powered by FUDForum. Page generated in 0.03274 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top