Uploaded on

 

More in: Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,860
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
45
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SWTBot UI test automation framework Cristian Tepus – Software Engineer
  • 2. 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
  • 3. 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 ();
  • 4. 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
  • 5. 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));
  • 6. 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; );
  • 7. 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 ();
  • 8. Screenshots
    • SWTBot generates a screenshot when an error occurs. The screenshot will be saved and available within the test plugin’s directory
  • 9. 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)
  • 10. 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.
  • 11. 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