Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Getting Teststeps from swtbot
Getting Teststeps from swtbot [message #506819] Sun, 10 January 2010 11:37 Go to next message
Michelle Davidson is currently offline Michelle Davidson
Messages: 41
Registered: August 2009
Member
Hello,

is there a way to log the the steps of a test.
For exampel.


  1. Select Treeitem "test"
  2. click contextMenuItem "edit"
  3. choose shell "edit"
  4. deselect radiobutton "delete"
  5. click button "ok"


Is there a chance to get such entries or something like that.

I dont know all findWidgets texts, but the actions, which I make in the applications. I want to put them in a protocol later. So a developer, canfaster reproduce the testcase with a failure.
Re: Getting Teststeps from swtbot [message #506951 is a reply to message #506819] Mon, 11 January 2010 08:54 Go to previous messageGo to next message
Pascal G is currently offline Pascal G
Messages: 157
Registered: July 2009
Senior Member
Michelle Davidson wrote:
> Hello,
>
> is there a way to log the the steps of a test. For exampel.
>
> Select Treeitem "test"
> click contextMenuItem "edit"
> choose shell "edit"
> deselect radiobutton "delete"
> click button "ok"
>
>
> Is there a chance to get such entries or something like that.
>
> I dont know all findWidgets texts, but the actions, which I make in the
> applications. I want to put them in a protocol later. So a developer,
> canfaster reproduce the testcase with a failure.

SWTBot uses log4j to log all sorts of information. All you need to do is
setup your log4j.xml to tell log4j what to log to what priority. There
is an example of this in the tests of SWTBot; checkout the latest source
from svn and check this file:
org.eclipse.swtbot.eclipse.finder.test/src/log4j.xml

Hope this helps.
--
Pascal GĂ©linas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Getting Teststeps from swtbot [message #508167 is a reply to message #506951] Sat, 16 January 2010 23:28 Go to previous messageGo to next message
Michelle Davidson is currently offline Michelle Davidson
Messages: 41
Registered: August 2009
Member
Hello,

Thanks for the answer. I have tried that. But now I have too much log statements. I want only action like click, activate, type or something like this. But I also get the log statements for sending events from the class Abstract SWTBot. Because both have the loglevel debug and the class AbstractSWTBot is in the same package like the widget classes.

Is the chance to get only the statements for the actions and not for the events.

I tried to set the loglevel for the class Abstract SWTBot to OFF and for the package ....widgets to DEBUG. But I get also this.

Quote:
17 Jan 2010 00:17:48.332 - WorkbenchTestable - TRACE - SWTBotButton - (AbstractSWTBot.java:151) - Enquing event Deactivate [27]: ShellEvent{Button {*Disposed*} time=963483308 data=null doit=true} on (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')
17 Jan 2010 00:17:48.332 - main - TRACE - SWTBotButton - (AbstractSWTBot$2.java:155) - Not notifying (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH') is null or has been disposed
17 Jan 2010 00:17:48.332 - WorkbenchTestable - TRACE - SWTBotButton - (AbstractSWTBot.java:151) - Enquing event FocusOut [16]: FocusEvent{Button {*Disposed*} time=963483308 data=null} on (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')
17 Jan 2010 00:17:48.334 - main - TRACE - SWTBotButton - (AbstractSWTBot$2.java:155) - Not notifying (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH') is null or has been disposed
17 Jan 2010 00:17:48.334 - WorkbenchTestable - DEBUG - SWTBotButton - (SWTBotButton.java:78) - Clicked on
17 Jan 2010 00:17:48.335 - WorkbenchTestable - TRACE - SWTBotTreeItem - (AbstractSWTBot.java:151) - Enquing event Expand [17]: TreeEvent{Tree {} time=963483311 data=null item=TreeItem {Root} detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true} on TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.335 - main - TRACE - SWTBotTreeItem - (AbstractSWTBot$2.java:162) - Sending event Expand [17]: TreeEvent{Tree {} time=963483311 data=null item=TreeItem {Root} detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true} to TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.336 - main - DEBUG - SWTBotTreeItem - (AbstractSWTBot$2.java:164) - Sent event Expand [17]: TreeEvent{Tree {} time=963483311 data=null item=TreeItem {Root} detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true} to TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.340 - WorkbenchTestable - TRACE - SWTBotTreeItem - (AbstractSWTBot.java:151) - Enquing event MouseMove [5]: MouseEvent{Tree {} time=963483313 data=null button=0 stateMask=0 x=0 y=0 count=0} on TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.340 - main - TRACE - SWTBotTreeItem - (AbstractSWTBot$2.java:162) - Sending event MouseMove [5]: MouseEvent{Tree {} time=963483313 data=null button=0 stateMask=0 x=0 y=0 count=0} to TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.341 - main - DEBUG - SWTBotTreeItem - (AbstractSWTBot$2.java:164) - Sent event MouseMove [5]: MouseEvent{Tree {} time=963483313 data=null button=0 stateMask=0 x=0 y=0 count=0} to TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.341 - WorkbenchTestable - TRACE - SWTBotTreeItem - (AbstractSWTBot.java:151) - Enquing event Activate [26]: ShellEvent{Tree {} time=963483317 data=null doit=true} on TreeItem with text {TreeItem {Root}}
17 Jan 2010 00:17:48.342 - main - TRACE - SWTBotTreeItem - (AbstractSWTBot$2.java:162) - Sending event Activate [26]: ShellEvent{Tree {} time=963483317 data=null doit=true} to TreeItem with text {TreeItem {Root}}



That was a part of the log file.

This is my log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
	debug="false">

	<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
		<param name="Target" value="System.out" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern"
				value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
		</layout>
	</appender>
 
	<appender name="fileAppender" class="org.apache.log4j.FileAppender">
		<param name="File" value="/tmp/debug.log" />
		<param name="Append" value="true" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern"
				value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} - (%C{1}.java:%L) - %m%n" />
		</layout>
	</appender>
	
	<!-- don't log matchers, this is very high amount of chatter -->
	<category name="org.eclipse.swtbot.swt.finder.matchers">
		<priority value="OFF" />
	</category>

	<!--
		don't log the class AbstractSWTBot but all other classes from this package
	-->	
	<category name="org.eclipse.swtbot.swt.finder.widgets">
		<priority value="ALL" />
	</category>
	
		<category name="org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot">
		<priority value="OFF" />
		</category>	

	<!-- don't log finders, this is moderate chatter -->
	<category name="org.eclipse.swtbot.swt.finder.finders">
		<priority value="OFF" />
	</category>

	<category name="org.eclipse.swtbot.swt.finder.keyboard">
		<!-- set to a value higher than debug to turn on. -->
		<priority value="DEBUG" />
	</category>


	<category name="org.eclipse.swtbot">
		<priority value="ALL" />
	</category>

	<root>
		<priority value="DEBUG" />
		<!--appender-ref ref="consoleAppender" /-->
		<appender-ref ref="fileAppender" />
	</root>
	
</log4j:configuration>
Re: Getting Teststeps from swtbot [message #508541 is a reply to message #508167] Tue, 19 January 2010 11:40 Go to previous message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
I guess a grep pattern is the only way to do this. You may potentially
write your own Appender implementation[1] that logs only if certain
keywords are present in the log statement.

-- Ketan


[1] -
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j /FileAppender.html

On 1/16/10 3:28 PM, Michelle Davidson wrote:
> Hello,
>
> Thanks for the answer. I have tried that. But now I have too much log
> statements. I want only action like click, activate, type or something
> like this. But I also get the log statements for sending events from the
> class Abstract SWTBot. Because both have the loglevel debug and the
> class AbstractSWTBot is in the same package like the widget classes.
> Is the chance to get only the statements for the actions and not for the
> events.
>
> I tried to set the loglevel for the class Abstract SWTBot to OFF and for
> the package ....widgets to DEBUG. But I get also this.
>
> Quote:
>> 17 Jan 2010 00:17:48.332 - WorkbenchTestable - TRACE - SWTBotButton -
>> (AbstractSWTBot.java:151) - Enquing event Deactivate [27]:
>> ShellEvent{Button {*Disposed*} time=963483308 data=null doit=true} on
>> (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')
>> 17 Jan 2010 00:17:48.332 - main - TRACE - SWTBotButton -
>> (AbstractSWTBot$2.java:155) - Not notifying (of type 'Button' and with
>> mnemonic 'OK' and with style 'SWT.PUSH') is null or has been disposed
>> 17 Jan 2010 00:17:48.332 - WorkbenchTestable - TRACE - SWTBotButton -
>> (AbstractSWTBot.java:151) - Enquing event FocusOut [16]:
>> FocusEvent{Button {*Disposed*} time=963483308 data=null} on (of type
>> 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')
>> 17 Jan 2010 00:17:48.334 - main - TRACE - SWTBotButton -
>> (AbstractSWTBot$2.java:155) - Not notifying (of type 'Button' and with
>> mnemonic 'OK' and with style 'SWT.PUSH') is null or has been disposed
>> 17 Jan 2010 00:17:48.334 - WorkbenchTestable - DEBUG - SWTBotButton -
>> (SWTBotButton.java:78) - Clicked on 17 Jan 2010 00:17:48.335 -
>> WorkbenchTestable - TRACE - SWTBotTreeItem - (AbstractSWTBot.java:151)
>> - Enquing event Expand [17]: TreeEvent{Tree {} time=963483311
>> data=null item=TreeItem {Root} detail=0 x=0 y=0 width=0 height=0
>> stateMask=0 text=null doit=true} on TreeItem with text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.335 - main - TRACE - SWTBotTreeItem -
>> (AbstractSWTBot$2.java:162) - Sending event Expand [17]:
>> TreeEvent{Tree {} time=963483311 data=null item=TreeItem {Root}
>> detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true} to
>> TreeItem with text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.336 - main - DEBUG - SWTBotTreeItem -
>> (AbstractSWTBot$2.java:164) - Sent event Expand [17]: TreeEvent{Tree
>> {} time=963483311 data=null item=TreeItem {Root} detail=0 x=0 y=0
>> width=0 height=0 stateMask=0 text=null doit=true} to TreeItem with
>> text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.340 - WorkbenchTestable - TRACE - SWTBotTreeItem
>> - (AbstractSWTBot.java:151) - Enquing event MouseMove [5]:
>> MouseEvent{Tree {} time=963483313 data=null button=0 stateMask=0 x=0
>> y=0 count=0} on TreeItem with text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.340 - main - TRACE - SWTBotTreeItem -
>> (AbstractSWTBot$2.java:162) - Sending event MouseMove [5]:
>> MouseEvent{Tree {} time=963483313 data=null button=0 stateMask=0 x=0
>> y=0 count=0} to TreeItem with text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.341 - main - DEBUG - SWTBotTreeItem -
>> (AbstractSWTBot$2.java:164) - Sent event MouseMove [5]:
>> MouseEvent{Tree {} time=963483313 data=null button=0 stateMask=0 x=0
>> y=0 count=0} to TreeItem with text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.341 - WorkbenchTestable - TRACE - SWTBotTreeItem
>> - (AbstractSWTBot.java:151) - Enquing event Activate [26]:
>> ShellEvent{Tree {} time=963483317 data=null doit=true} on TreeItem
>> with text {TreeItem {Root}}
>> 17 Jan 2010 00:17:48.342 - main - TRACE - SWTBotTreeItem -
>> (AbstractSWTBot$2.java:162) - Sending event Activate [26]:
>> ShellEvent{Tree {} time=963483317 data=null doit=true} to TreeItem
>> with text {TreeItem {Root}}
>
>
> That was a part of the log file.
>
> This is my log4j.xml
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
> debug="false">
>
> <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
> <param name="Target" value="System.out" />
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern"
> value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} -
> (%C{1}.java:%L) - %m%n" />
> </layout>
> </appender>
>
> <appender name="fileAppender" class="org.apache.log4j.FileAppender">
> <param name="File" value="/tmp/debug.log" />
> <param name="Append" value="true" />
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern"
> value="%d{dd MMM yyyy HH:mm:ss.SSS} - %25t - %-5p - %30c{1} -
> (%C{1}.java:%L) - %m%n" />
> </layout>
> </appender>
>
> <!-- don't log matchers, this is very high amount of chatter -->
> <category name="org.eclipse.swtbot.swt.finder.matchers">
> <priority value="OFF" />
> </category>
>
> <!--
> don't log the class AbstractSWTBot but all other classes from this package
> -->
> <category name="org.eclipse.swtbot.swt.finder.widgets">
> <priority value="ALL" />
> </category>
>
> <category name="org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot" >
> <priority value="OFF" />
> </category>
>
> <!-- don't log finders, this is moderate chatter -->
> <category name="org.eclipse.swtbot.swt.finder.finders">
> <priority value="OFF" />
> </category>
>
> <category name="org.eclipse.swtbot.swt.finder.keyboard">
> <!-- set to a value higher than debug to turn on. -->
> <priority value="DEBUG" />
> </category>
>
>
> <category name="org.eclipse.swtbot">
> <priority value="ALL" />
> </category>
>
> <root>
> <priority value="DEBUG" />
> <!--appender-ref ref="consoleAppender" /-->
> <appender-ref ref="fileAppender" />
> </root>
>
> </log4j:configuration>
Previous Topic:ShellIsActive wait condition
Next Topic:How to find the matches in Build Console View
Goto Forum:
  


Current Time: Sun Sep 21 20:31:13 GMT 2014

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

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