Module: OnlyofficeWebdriverWrapper::WebdriverFrameMethods

Included in:
WebDriver
Defined in:
lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_frame_methods.rb

Overview

Methods for webdriver frame operations

Instance Method Summary collapse

Instance Method Details

#select_frame(xpath_name = '//iframe', count_of_frames = 1) ⇒ nil

Select frame as current

Parameters:

  • xpath_name (String) (defaults to: '//iframe')

    name of current xpath

  • count_of_frames (Integer) (defaults to: 1)

    how much times select xpath_name

Returns:

  • (nil)


10
11
12
13
14
15
16
17
18
19
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_frame_methods.rb', line 10

def select_frame(xpath_name = '//iframe', count_of_frames = 1)
  (0...count_of_frames).each do
    frame = @driver.find_element(:xpath, xpath_name)
    @driver.switch_to.frame frame
  rescue Selenium::WebDriver::Error::NoSuchElementError
    OnlyofficeLoggerHelper.log('Raise NoSuchElementError in the select_frame method')
  rescue StandardError => e
    webdriver_error("Raise unknown exception: #{e}")
  end
end

#select_top_framenil

Select top frame of browser (even if several sub-frames exists)

Returns:

  • (nil)


23
24
25
26
27
28
29
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_frame_methods.rb', line 23

def select_top_frame
  @driver.switch_to.default_content
rescue Timeout::Error
  OnlyofficeLoggerHelper.log('Raise TimeoutError in the select_top_frame method')
rescue StandardError => e
  raise "Browser is crushed or hangup with error: #{e}"
end