Module: OnlyofficeWebdriverWrapper::WebdriverStyleHelper

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

Overview

Webdriver style helper

Instance Method Summary collapse

Instance Method Details

#get_style_parameter(xpath, parameter_name) ⇒ String?

Get style parameter of object

Parameters:

  • xpath (String)

    to find object

  • parameter_name (String)

    which parameter to get

Returns:

  • (String, nil)

    nil if there is no such param



10
11
12
13
14
15
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_style_helper.rb', line 10

def get_style_parameter(xpath, parameter_name)
  get_attribute(xpath, 'style').split(';').each do |current_param|
    return /:\s(.*);?$/.match(current_param)[1] if current_param.include?(parameter_name)
  end
  nil
end

#set_style_attribute(xpath, attribute, attribute_value) ⇒ String Also known as: set_style_parameter

Set style attribute value of element

Parameters:

  • xpath (String)

    xpath to set

  • attribute (String)

    style param to set

  • attribute_value (String)

    attribute value to set

Returns:

  • (String)

    result of execution



22
23
24
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_style_helper.rb', line 22

def set_style_attribute(xpath, attribute, attribute_value)
  execute_javascript("#{dom_element_by_xpath(xpath)}.style.#{attribute}=\"#{attribute_value}\"")
end

#set_style_show_by_xpath(xpath, move_to_center = false) ⇒ void

This method returns an undefined value.

Show element by changing it css style

Parameters:

  • xpath (String)

    to find object

  • move_to_center (Boolean) (defaults to: false)

    should object be moved to center of screen



32
33
34
35
36
37
38
# File 'lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_style_helper.rb', line 32

def set_style_show_by_xpath(xpath, move_to_center = false)
  execute_javascript("#{dom_element_by_xpath(xpath)}.style.display = 'block';")
  return unless move_to_center

  execute_javascript("#{dom_element_by_xpath(xpath)}.style.left = '410px';")
  execute_javascript("#{dom_element_by_xpath(xpath)}.style.top = '260px';")
end