Swtbot
Upcoming SlideShare
Loading in...5
×
 

Swtbot

on

  • 2,190 views

 

Statistics

Views

Total Views
2,190
Views on SlideShare
2,190
Embed Views
0

Actions

Likes
0
Downloads
45
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Swtbot Swtbot Presentation Transcript

  • SWTBot UI test automation framework Cristian Tepus – Software Engineer
  • Introduction
    • SWTBot is an open-source Java based UI/functional testing tool for testing SWT and Eclipse based applications.
    • SWTBot project is in Incubation Phase in Eclipse
    • Latest version is 2.0.0.568
    • Similar to a click-robot, it solves SWT handling complexity by providing easy UI API
    • SWTBot’s API can integrate in JUnit framework in order to develop and run test cases
  • Starting with example
    • SWTWorkbenchBot bot = new SWTWorkbenchBot();
    • // click on a button with the given text
    • SWTBotButton button = bot. button ( "Hello, World!" );
    • button. click ();
    • // click on the File>New menu item
    • SWTBotMenu file = bot. menu ( "File" );
    • SWTBotMenu new = file. menu ( "New" ); new. click ();
  • Finding widgets
    • // find the textbox that has a label 'Username:‘
    • SWTBotText username = bot.textWithLabel("Username:");
    • // Easily identify buttons using the tooltip
    • SWTBotToolbarButton save = bot.toolbarButtonWithTooltip("Save");
    • // find windows using the window title
    • SWTBotShell shell = bot.shell("New Project Wizard");
    • You can find controls using:
    • text
    • label
    • group
    • tooltip
    • ids
    • combination of all or any of the above
  • Custom matchers
    • import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory .*;
    • // match :
    • // widgets of type 'Label'
    • // with regular expression 'Welcome, <USERNAME>'
    • Matcher matcher = allOf(
    • widgetOfType(Label. class ),
    • withRegex( &quot;Welcome, .*&quot; ) );
    • // get the label that matches the matcher
    • SWTBotLabel label = new SWTBotLabel((Label) bot. widget (matcher));
  • Perform actions on widgets
    • button. click ();
    • radioButton. select ();
    • comboBox. select ( “Option 12&quot; );
    • text. typeText ( “This is a demo string&quot; );
    • tree. expandNode ( &quot;MyProject&quot; , &quot;src&quot; , &quot;com&quot; , &quot;example&quot; , &quot;MyClass.java&quot; );
  • Querying widgets for state
    • SWTBot provides a few operations to query the state of widgets. Some generic queries like: getText(), isEnabled(), isVisible() are available on all widgets
    • Ex.
    • boolean checked = checkbox. isChecked ();
    • boolean selected = radio. isSelected ();
  • Screenshots
    • SWTBot generates a screenshot when an error occurs. The screenshot will be saved and available within the test plugin’s directory
  • Test Execution
    • SWTBot framework allows for tests to be executed in 2 ways:
    • Manually, by launching them from launch configuration (similar with junit tests);
    • From command line, using shell script or ant. For this mode, headless execution framework is necessary (see http://wiki.eclipse.org/SWTBot/Ant for more details)
  • What’s new in Eclipse Helios
    • Updated to support Junit 4.8 instead 4.7 (included Categories).
    • Bug Fixes:
      • 300103 - SWTBotGefEditor.directEditType does not work
      • 301260 - SWTBotGefEditor.mouseDrag(String,int,int) doesn't drag node, it reduces them
      • 305430 - Create the parent screenshot dir when capturing the screenshot.
  • Useful links
    • http://www.eclipse.org/swtbot/
    • http://download.eclipse.org/technology/swtbot/helios/dev-build/apidocs/
    • http://swtbot.org/user-guide/basics-of-swtbot.html
    • http://wiki.eclipse.org/SWTBot/Ant
    • http://github.com/ketan/swtbot
    • https://publications.theseus.fi/bitstream/handle/10024/7470/Mazurkiewicz_Milosz.pdf?sequence=2