Sha256: 7b7b1972b6ec3c5811bfd5d1570375ebf815257524214d219c3b59566554b4a8

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

module SeleniumToCapybara

  # This class holds the translations for minitest.
  #
  # To add a translation you need to do the following steps:
  # 1. Open the .side file and find the command you want to add
  # 2. Define a method in the Minitest class with the command as name.
  #    The command name must be translated to the ruby version of the name. `assertText` => `assert_text`
  # 3. Define the translation
  #
  # The properties of the whole .side command object are accessible through ruby methods.
  # - `target` is the preferred target selector of Selenium IDE
  # - `targets` holds all possible target selectors identified by Selenium IDE
  # - `selector_type` identifies the type of the preferred target selector (e.g css, xpath)
  # - `selector` is the selector of the preferred target selector itself. (e.g 'body .header .title')
  # - `value` e.g. the value that a text field should get
  # - `command` the command name itself like `assertText` or `click`
  # - `comment` a optional comment for that command
  # - `id` the internal id generated by Selenium IDE
  class Minitest < Base
    def open
      "visit('#{target}')"
    end

    def double_click
      case selector_type
      when 'css'
        "find('#{selector}').double_click"
      when 'id'
        "find('##{selector}').double_click"
      when 'xpath'
        "find('#{selector}').double_click"
      when 'name'
        "find('[name=\"#{selector}\"]').double_click"
      end
    end

    def click
      case selector_type
      when 'css'
        "find('#{selector}').click"
      when 'id'
        "find('##{selector}').click"
      when 'xpath'
        "find('#{selector}').click"
      when 'name'
        "find('[name=\"#{selector}\"]').click"
      when 'linkText'
        "click_link_or_button('#{selector}')"
      end
    end

    def assert_text
      "assert_selector('#{selector}', text: '#{value}')"
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selenium_to_capybara-0.1.4 lib/selenium_to_capybara/minitest.rb