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.Selenium/WebDriver Bindings

MarathonITE provides access to Selenium/WebDriver bindings to your scripts. This extends Selenium/WebDriver bindings for Ruby. When you access a component in MarathonITE using get_component, the object you receive is a WebElement. You can perform any of the standard WebDriver operations on this WebElement. You can use any Selenium/WebDriver calls and intersperse them with MarathonITE calls. This provides your scripts the power and flexibility they may need for implementing complex scenarios.

MarathonITE Java Drivers implement Selenium JSON Wire Protocol

MarathonITE uses marathon java drivers. The drivers implement Selenium/WebDriver JSONWireProtocol – the protocol used by WebDriver instances to communicate with browsers. Marathon JavaDriver implements the protocol and enhances it to work with Java/Swing™ and Java/FX™ applications. Testers who are familiar with Selenium/WebDriver can take advantage of this integration. For Web applications, MarathonITE uses standard Selenium drivers with enhancements for recording functionality.

Selenium/WebDriver Commands and Operations

Finding Elements

Finding elements in JavaDriver can be done on the JavaDriver i.e driver instance itself or on a WebElement. The java driver instance is available as driver within the script. You can use find_element and find_elements methods to access the components. The former returns a WebElement object matching the selector, and throws an exception if such an element cannot be found. The latter returns a list of WebElements, possibly empty if no elements match the selector.

The find_element(s) methods take selector. Different kinds of selector available are list below

By ClassName

ClassName in this case refers to fully qualified class names of Java/Swing Components or Java/FX Controls.

Example:

To find JTable (whose fully qualified class name is javax.swing.JTable) using ClassName, you can use following code in your script:

By TagName

A tagname is computed by finding the Swing/AWT or Java/FX superclass of the component or control and converting CamelCase to camel-case.

Example:

To find JTextField (whose computed tag name will be text-field) using TagName, you can use following code in your script

By Name

A name in this case refers to attribute that is set through, for Java/Swing java.awt.Component#setName and for Java/FX javafx.scene.Node#setId method.

Example:

To find JList (whose name is "Places") using Name, you can use following code in your script

By CSS

CSS here refers to attributes or properties of components (like name, id, rowCount, orientation etc.). You can use :pseudoclass, ::pseduoelement as a CSS selector.

Examples:

To find JList (whose name is "Places") using css, you can use following code in your script

To find JCheckBox using pseudoclass as css selector

To find JList's nth-item using pseudoelement as css selector

Getting attributes

You can get Java/Swing Component's or Java/FX Control's attribute using WebElement's attribute method. It always returns string value. Any property which is visible can be retrieved through attribute method.

Example:

To retrieve attribute starting with get. To get JList#getRowCount property use below code. (i.e getPropertyName => propertName)

To retrieve attribute starting with is. To get JCheckBox#isSelecetd property use below code. (i.e isPropertyName => propertName)

To retrieve attribute starting with has. To get JTable#hasFocus property use below code. (i.e hasPropertyName => propertName)

To retrieve attribute i.e x.y. To get JList#getSelectedIndices#getSize property use below code. (i.e getPropertyName1.getPropertyName2 => propertName1.propertyName2)

It also applies for attribute i.e x.y.z.

To retrieve attribute that does not starts with get, is and has. To get some property use below code. (i.e propertyName => propertName)

User Input

MarathonITE itself internally uses WebDriver calls to implement script elements like select and click.

Example:

MarathonIte records text-field input with its naming property and text value, as

Similarly you can use WebDriver's send_keys method to fill text-field

Moving Between Windows

Some applications have multiple windows. JavaDriver supports moving between windows using the “switchTo” method as in WebDriver:

Alternatively, you can pass a “window handle” to the switchTo().window() method. Knowing this, it’s possible to iterate over every open window like so:

Drag and Drop

Here’s an example of using the Actions class to perform a drag and drop. ruby list_item_1 = driver.find_element(:css, "list::nth-item(1)") list_item_2 = driver.find_element(:css, "list::nth-item(5)") driver.action.drag_and_drop(list_item_1, list_item_2).perform

Explicit Waits

An explicit wait is code you define to wait for a certain condition to occur before proceeding further in the code. Below is an example of using Explicit Wait to wait for check-box to selected.

Taking a Screenshot

Here's a example of using JavaDriver to take screenshot

Suggest Edit