Search code examples
javajrubymarathontesting

Finding text and using its location in Marathon Testing Tool/JRuby


Using Marathon to test a java application, I have a handful of rows and I want to commit some operations on a specific row that has certain text in one of its fields.

How would I go about searching for it and then selecting it to use it in Marathon or JRuby?

For example, I want to find the text "HERE" in a row, right click that row, and click one of the options provided.


Solution

  • There are two ways you can do this.

    1. You can fall back to WebDriver interfaces and use find_elements.

      table = get_component('oscarTable')
      cells = table.find_elements(:css, '.::all-cells[text="102 Dalmatians"]')
      cells.each { |c| puts c.text }
      
    2. Use text property and access the cell directly

      cell = get_component('oscarTable', { :text => '102 Dalmatians' })
      puts cell.text
      

    In (2) you can use select instead of get_component to set the value of the cell (if the cell is editable etc.)