Class: SeleniumHelperTemplate
- Defined in:
- lib/generators/templates/helpers/selenium_helper_template.rb
Instance Method Summary collapse
Methods inherited from Template
Constructor Details
This class inherits a constructor from Template
Instance Method Details
#body ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generators/templates/helpers/selenium_helper_template.rb', line 4 def body " require 'selenium-webdriver'\n require_relative 'driver_helper'\n\n module Raider\n module SeleniumHelper\n def click_when_present\n # This is an example of an implicit wait in selenium\n wait = Selenium::WebDriver::Wait.new(timeout: 15)\n wait.until { present? }\n click\n end\n\n def select_by(key, value)\n # Creates new Select object to use the select by method\n dropdown = Selenium::WebDriver::Support::Select.new self\n dropdown.select_by(key, value)\n end\n\n def hover\n # Using actions to move the mouse over an element\n DriverHelper.driver.action.move_to(self).perform\n end\n\n # How to perform right click through the context click method\n def right_click\n DriverHelper.driver.action.context_click(self).perform\n end\n end\n\n # Here we are opening the selenium class and adding our custom method\n class Selenium::WebDriver::Element\n include SeleniumHelper\n end\n end\n EOF\nend\n" |