class Page

Constants

CONFIG
STAND

Public Class Methods

driver() click to toggle source
# File lib/page.rb, line 16
def self.driver
  Driver.instance.browser
end
new(visit = false) click to toggle source
Calls superclass method
# File lib/page.rb, line 20
def initialize(visit = false)
  super(Page.driver, visit)
end

Public Instance Methods

close_other_windows() click to toggle source

close all windows except current

# File lib/page.rb, line 45
def close_other_windows
  cur_window = browser.window_handle
  browser.window_handles.each do |window|
    next if window.eql?(cur_window)

    browser.switch_to.window(window)
    browser.close
  end
  browser.switch_to.window(cur_window)
end
code_mirror(id) click to toggle source
# File lib/page.rb, line 35
def code_mirror(id)
  execute_script("return $('##{id}').val();")
end
switch_next_window() click to toggle source

switch to next window and close current

# File lib/page.rb, line 57
def switch_next_window
  cur_window = browser.window_handle
  browser.close
  browser.window_handles.each do |window|
    next if window.eql?(cur_window)

    browser.switch_to.window(window)
    break
  end
end
type_ck_editor(id, text) click to toggle source

deal with ck editor text areas

# File lib/page.rb, line 40
def type_ck_editor(id, text)
  execute_script("CKEDITOR.instances['#{id}'].insertText('#{text}');")
end
type_code_mirror(id, text) click to toggle source

deal with code mirror text areas

# File lib/page.rb, line 30
def type_code_mirror(id, text)
  execute_script("$('##{id}').val('#{text}');")
  execute_script("$('##{id}').keyup();")
end
upload_file(element, file_path) click to toggle source

direct upload files via window upload dialog

# File lib/page.rb, line 25
def upload_file(element, file_path)
  element.send_keys(file_path.tr('/', '\\'))
end