1. Preface
    1. About MarathonITE
    2. Supported Platforms
      1. Java/Swing™
      2. Java/FX™
      3. Web Applications
    3. What's New in MarathonITE 5.0
    4. Change Log a.k.a Version History
    5. System Requirements
    6. Copyright Notice
  2. Getting Started
    1. Introduction to Test Automation
      1. Unattended Testing
      2. Semi Automated Testing
      3. Exploratory Testing
    2. MarathonITE Projects
    3. Your First Project
      1. Java/Swing™ Test Project
        1. Application Under Test - SwingSet3
        2. Creating a Project
        3. Recording a Test
        4. Anatomy of a Test Script
        5. Running Tests
        6. Looking at Results
      2. Java/FX™ Test Project
        1. Application Under Test - Ensemble
        2. Creating a Project
        3. Recording a Test
        4. Anatomy of a Test Script
        5. Running Tests
        6. Looking at Results
      3. Web Application Test Project
        1. Application Under Test - DuckDuckGo Search
        2. Creating a Project
        3. Recording a Test
        4. Anatomy of a Test Script
        5. Running Tests
        6. Looking at Results
    4. MarathonITE Sample Projects
  3. User Guide
    1. Installation and Startup
    2. MarathonITE User Interface
      1. Views
      2. Editors
      3. Output Views
    3. Creating Marathonite Test Projects
    4. Recording Tests
    5. Managing Checklists
    6. Exploratory Tests
    7. Semi Automated Tests
    8. Executing Tests
      1. Executing a Test from Editor
        1. Debugging Scripts
        2. Using Script Console
      2. Executing Tests from Test Runner
      3. Executing Tests in Batch Mode
    9. Organizing Tests
      1. Organizing Tests in Folder Heirarchy
      2. Organizing Tests as Features and Stories
      3. Organizing Tests in Suites
      4. Linking Tests to TMS and Issue Manager
    10. Modularizing Test Scripts
      1. Module Methods
      2. Extract Method Refactoring
      3. Using Data Loops
      4. Convert to Data Loop Refactoring
    11. Data Driven Tests
      1. Convert to DDT Refactoring
  4. Advanced Scripting
    1. Ruby Programming Language
    2. Marathon and Ruby
    3. Selenium/WebDriver Bindings
      1. Java/Swing™ Components
      2. Java/FX™ Controls

4.3.1.Java/Swing™ Components

MarathonITE implements a CSS finder for Java applications. You can use WebDriver’s find_element(s) call to quickly find a component in the application.

Under this section, we will go through different kinds of selectors that are available.

Simple Selectors

Some of the simple selectors are tagname, * (all), . (self).

Selector Description Example
tagname Selects an element with the given tagname. A tagname is computed by finding the Swing/AWT superclass of the component and converting CamelCase to camel-case. JSpinner -> spinner, JTextField -> text-field
* Universal Gets all the elements. It retuns list of elements. driver.find_elements(:css, "*")
. Self It returns the same element.
  • tree = driver.find_element(:css, "tree")
  • tree_1 = tree.find_element(:css, ".")
tree and tree_1 are same.
#name Select a component with the given name. If component has name : (set through java.awt.Component#setName method), you find component using #component_name.

Above listed selectors can be used on all components.

Other Selectors

Selector Description Example
[attribute <operation> value] Find components with the given value for the attribute. The operation can be *= (contains), /= (regex match), = (equals), ^= (startswith), $= (endswith). button[text="Click Me!!"]. This selector finds all the buttons whose text is equal to “Click Me!!”
:<pseudoclass>: Find components for which <pseudoclass> returns true. Pseudoclasses avaiable are selected, enabled, displayed, hidden and instance-of("&lt;class>"). text-field:enabled. This selector finds all the text-fields which are enabled.
:: PseudoElements: This selector finds the pseudo elements. driver.find_elements(:css, "combo-box::all-options")

Operations on components

Below is the list of components and the selectors that can be used for it, with examples

JButton

Using [attribute <operation> value]

Using <pseudoclass>

JComboBox

Using [attribute <operation> value]

Using <pseudoclass>

Using <pseudoeelement>: Available pseudoelements are nth-option(index) and all-options.

JList

Using [attribute <operation> value] ruby list = driver.find_element(:css, "list[name ^= "Places"]")

Using <pseudoclass>

Using <pseudoeelement>: Available pseudoelements are nth-item(index) and all-items.

JEditorPane

Using [attribute <operation> value]

Using <pseudoclass>

Using <pseudoelement>: Available pseudoelements are tag(name), where name can be a, ol, ul etc. ruby editor = driver.find_element(:css, "editor-pane") editor.find_element(:css, ".::tag('a')[text='Title Page']"));

JTabbedPane

Using [attribute <operation> value]

Using <pseudoelement>: Available pseudoelements are nth-tab(index), all-tabs and selected-tab.

JTableHeader

Using <pseudoelement>: Available pseudoelements are nth-item(index) and all-items.

JTable

Using [attribute <operation> value]

Using <pseudoelement>: Available pseudoelements are header, mnth-cell(row, column), all-cells and mnth-cell-editor(row, column).

JTree

Using [attribute <operation> value]

Using <pseudoelement>: Available pseudoelements are nth-node(index), all-nodes and root.

Getting attributes

People often wish to text from a component. This returns a string value.

You can use above code in marathon test scripts to get button’s text.

The web driver instance is available as driver within the script. You can access Java Component’s attribute using webdriver’s attribute method.

For example: If you want to get row count from JTable

Webdriver’s attribute method always return String.

Suggest Edit