onlyoffice_webdriver_wrapper 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdfe224abc7b1f2c7e69e8830ec5cc388d3b8fa165a969f8860a832e1ab51319
4
- data.tar.gz: cf61e06fce72afbb30398cdd62693544107059701316698705da602231eb7d9a
3
+ metadata.gz: 643b10c1d669416dbc430566e360d7ccec6ea147d42f37707a0534b734bc1d98
4
+ data.tar.gz: 0e8b63041f0e9db6a2415f9aaa9eb966866d6555479bfec7f93c983011b5500b
5
5
  SHA512:
6
- metadata.gz: '061282552a87103e53e3d94f4ce3be7d8a811378ad6d64c1620089b7f259ce231c8d7de931d8a60c83a7b601c31f599b7ccf3e92a4d86ae22efae2f5d8f5b6c6'
7
- data.tar.gz: 7d0d8e1528f07f2a8bca61a972acf872075870ffd2dba37b088e9969c4b2f8d9ed91baee62df2a2b732930a77c9e0b0760541b743496d333cdc464c61ce08d5e
6
+ metadata.gz: 117134c44e8598f311bf93bf457bbd4768b9eafbc6b97c8fc294c9b584143623a64473b733952b7539d5f0b1663a2da3b80d6c60f5866391a4e3870195e4326e
7
+ data.tar.gz: d9e14fc44a181d86a6a8c85e9b8c89f2d41c279ab19a8cd00c8d209dcd4df55c1bbf98fee9059de3506cdd704315eb64588e062853b8563df3a035e44e5a0e37
@@ -21,7 +21,10 @@ module OnlyofficeWebdriverWrapper
21
21
  caps = Selenium::WebDriver::Remote::Capabilities.firefox
22
22
  caps[:proxy] = Selenium::WebDriver::Proxy.new(ssl: "#{@proxy.proxy_address}:#{@proxy.proxy_port}") if @proxy
23
23
  driver = Selenium::WebDriver.for :firefox, service: firefox_service, capabilities: [caps, options]
24
- driver.manage.window.size = Selenium::WebDriver::Dimension.new(headless.resolution_x, headless.resolution_y) if headless.running?
24
+ if headless.running?
25
+ driver.manage.window.size = Selenium::WebDriver::Dimension.new(headless.resolution_x,
26
+ headless.resolution_y)
27
+ end
25
28
  driver
26
29
  end
27
30
 
@@ -54,7 +54,7 @@ module OnlyofficeWebdriverWrapper
54
54
  destroy_at_exit: true,
55
55
  dimensions: "#{@resolution_x + 1}x#{@resolution_y + 1}x24",
56
56
  video: { provider: :ffmpeg })
57
- rescue Exception => e
57
+ rescue StandardError => e
58
58
  OnlyofficeLoggerHelper.log("xvfb not started with problem #{e}")
59
59
  WebDriver.clean_up(true)
60
60
  @headless_instance = Headless.new(reuse: false,
@@ -4,6 +4,6 @@ module OnlyofficeWebdriverWrapper
4
4
  # Module for storing version data
5
5
  module Version
6
6
  # @return [String] Current stable version of gem
7
- STRING = '1.9.0'
7
+ STRING = '1.10.0'
8
8
  end
9
9
  end
@@ -24,8 +24,10 @@ module OnlyofficeWebdriverWrapper
24
24
  begin
25
25
  count.times { element.click }
26
26
  rescue Selenium::WebDriver::Error::ElementNotInteractableError => e
27
- webdriver_error(e.class, "Selenium::WebDriver::Error::ElementNotInteractableError: element not visible for xpath: #{xpath_name}")
28
- rescue Exception => e
27
+ webdriver_error(e.class,
28
+ 'Selenium::WebDriver::Error::ElementNotInteractableError: ' \
29
+ "element not visible for xpath: #{xpath_name}")
30
+ rescue StandardError => e
29
31
  webdriver_error(e.class, "UnknownError #{e.message} #{xpath_name}")
30
32
  end
31
33
  end
@@ -38,7 +40,7 @@ module OnlyofficeWebdriverWrapper
38
40
  element = get_element_by_display(xpath_name)
39
41
  begin
40
42
  element.is_a?(Array) ? element.first.click : element.click
41
- rescue Exception => e
43
+ rescue StandardError => e
42
44
  webdriver_error(e.class, "Exception #{e} in click_on_displayed(#{xpath_name})")
43
45
  end
44
46
  end
@@ -40,7 +40,9 @@ module OnlyofficeWebdriverWrapper
40
40
  # @param [String] xpath_several_elements to find objects
41
41
  # @return [Array<String>] text of those elements
42
42
  def get_text_of_several_elements(xpath_several_elements)
43
- @driver.find_elements(:xpath, xpath_several_elements).filter_map { |element| element.text unless element.text == '' }
43
+ @driver.find_elements(:xpath, xpath_several_elements).filter_map do |element|
44
+ element.text unless element.text == ''
45
+ end
44
46
  end
45
47
  end
46
48
  end
@@ -12,7 +12,7 @@ module OnlyofficeWebdriverWrapper
12
12
  begin
13
13
  attribute_value = element.attribute(attribute)
14
14
  exist = !(attribute_value.empty? || attribute_value.nil?)
15
- rescue Exception
15
+ rescue StandardError
16
16
  exist = false
17
17
  end
18
18
  exist
@@ -13,7 +13,7 @@ module OnlyofficeWebdriverWrapper
13
13
  @driver.switch_to.frame frame
14
14
  rescue Selenium::WebDriver::Error::NoSuchElementError
15
15
  OnlyofficeLoggerHelper.log('Raise NoSuchElementError in the select_frame method')
16
- rescue Exception => e
16
+ rescue StandardError => e
17
17
  webdriver_error("Raise unknown exception: #{e}")
18
18
  end
19
19
  end
@@ -24,7 +24,7 @@ module OnlyofficeWebdriverWrapper
24
24
  @driver.switch_to.default_content
25
25
  rescue Timeout::Error
26
26
  OnlyofficeLoggerHelper.log('Raise TimeoutError in the select_top_frame method')
27
- rescue Exception => e
27
+ rescue StandardError => e
28
28
  raise "Browser is crushed or hangup with error: #{e}"
29
29
  end
30
30
  end
@@ -18,7 +18,7 @@ module OnlyofficeWebdriverWrapper
18
18
  # in that case performing `webdriver_error` only cause forever loop
19
19
  # since webdriver_error trying to get_url or make screenshots
20
20
  raise(e.class, "Timeout Error #{e} happened while executing #{script}")
21
- rescue Exception => e
21
+ rescue StandardError => e
22
22
  webdriver_error(e, "Exception #{e} in execute_javascript: #{script}")
23
23
  end
24
24
 
@@ -84,7 +84,7 @@ module OnlyofficeWebdriverWrapper
84
84
  # @param property [String] property to get
85
85
  # @return [String] value of property
86
86
  def computed_style(xpath, pseudo_element = 'null', property = nil)
87
- element_by_xpath = "document.evaluate(\"#{xpath.tr('"', "'")}\",document, null, XPathResult.ANY_TYPE, null ).iterateNext()"
87
+ element_by_xpath = dom_element_by_xpath(xpath)
88
88
  style = "window.getComputedStyle(#{element_by_xpath}, '#{pseudo_element}')"
89
89
  full_command = "#{style}.getPropertyValue('#{property}')"
90
90
  result = execute_javascript("return #{full_command}")
@@ -20,12 +20,16 @@ module OnlyofficeWebdriverWrapper
20
20
 
21
21
  # @return [String] url of current frame, or browser url if
22
22
  # it is a root frame
23
- def get_url
23
+ def current_url
24
24
  execute_javascript('return window.location.href')
25
25
  rescue Selenium::WebDriver::Error::NoSuchFrameError, Timeout::Error => e
26
26
  raise(e.class, "Browser is crushed or hangup with #{e}")
27
27
  end
28
28
 
29
+ alias get_url current_url
30
+ extend Gem::Deprecate
31
+ deprecate :get_url, 'current_url', 2069, 1
32
+
29
33
  # Refresh current page
30
34
  # @return [nil]
31
35
  def refresh
@@ -48,11 +52,11 @@ module OnlyofficeWebdriverWrapper
48
52
  begin
49
53
  @driver.execute_script('window.onbeforeunload = null') # off popup window
50
54
  rescue StandardError
51
- Exception
55
+ StandardError
52
56
  end
53
57
  begin
54
58
  @driver.quit
55
- rescue Exception => e
59
+ rescue StandardError => e
56
60
  OnlyofficeLoggerHelper.log("Some error happened on webdriver.quit #{e.backtrace}")
57
61
  end
58
62
  alert_confirm
@@ -22,7 +22,8 @@ module OnlyofficeWebdriverWrapper
22
22
  # Get screenshot of current windows and upload it to cloud storage
23
23
  # @param [String] path_to_screenshot place to store local screenshot
24
24
  # @return [String] url of public screenshot
25
- def get_screenshot_and_upload(path_to_screenshot = "#{screenshot_folder}/#{StringHelper.generate_random_string}.png")
25
+ def get_screenshot_and_upload(path_to_screenshot = nil)
26
+ path_to_screenshot ||= "#{screenshot_folder}/#{StringHelper.generate_random_string}.png"
26
27
  begin
27
28
  get_screenshot(path_to_screenshot)
28
29
  cloud_screenshot = publish_screenshot(path_to_screenshot)
@@ -57,20 +58,20 @@ module OnlyofficeWebdriverWrapper
57
58
  def webdriver_screenshot(screenshot_name = SecureRandom.uuid)
58
59
  begin
59
60
  link = get_screenshot_and_upload("#{screenshot_folder}/#{screenshot_name}.png")
60
- rescue Exception => e
61
+ rescue StandardError => e
61
62
  OnlyofficeLoggerHelper.log("Error in get screenshot: #{e}. Trying to get headless screenshot")
62
63
  if @headless.headless_instance.nil?
63
64
  system_screenshot("/tmp/#{screenshot_name}.png")
64
65
  begin
65
66
  link = publish_screenshot("/tmp/#{screenshot_name}.png")
66
- rescue Exception => e
67
+ rescue StandardError => e
67
68
  OnlyofficeLoggerHelper.log("Error in get screenshot: #{e}. System screenshot #{link}")
68
69
  end
69
70
  else
70
71
  @headless.take_screenshot("/tmp/#{screenshot_name}.png")
71
72
  begin
72
73
  link = publish_screenshot("/tmp/#{screenshot_name}.png")
73
- rescue Exception => e
74
+ rescue StandardError => e
74
75
  OnlyofficeLoggerHelper.log("Error in get screenshot: #{e}. Headless screenshot #{link}")
75
76
  end
76
77
  end
@@ -85,8 +85,13 @@ module OnlyofficeWebdriverWrapper
85
85
  end
86
86
 
87
87
  # @return [String] title of current tab
88
- def get_title_of_current_tab
88
+ def title_of_current_tab
89
89
  @driver.title
90
90
  end
91
+
92
+ alias get_title_of_current_tab title_of_current_tab
93
+
94
+ extend Gem::Deprecate
95
+ deprecate :get_title_of_current_tab, 'title_of_current_tab', 2069, 1
91
96
  end
92
97
  end
@@ -32,12 +32,17 @@ module OnlyofficeWebdriverWrapper
32
32
  # @param [Boolean] by_action type by `@driver.action` if true
33
33
  # @param [Boolean] by_element_send_key use `element.send_keys` if true
34
34
  # @return [void]
35
- def type_to_locator(xpath_name, text_to_send, clear_content = true, click_on_it = false, by_action = false, by_element_send_key = false)
35
+ def type_to_locator(xpath_name,
36
+ text_to_send,
37
+ clear_content = true,
38
+ click_on_it = false,
39
+ by_action = false,
40
+ by_element_send_key = false)
36
41
  element = get_element(xpath_name)
37
42
  if clear_content
38
43
  begin
39
44
  element.clear
40
- rescue Exception => e
45
+ rescue StandardError => e
41
46
  webdriver_error(e.class, "Error in element.clear #{e} for " \
42
47
  "type_to_locator(#{xpath_name}, #{text_to_send}, " \
43
48
  "#{clear_content}, #{click_on_it}, " \
@@ -81,8 +86,11 @@ module OnlyofficeWebdriverWrapper
81
86
  if click_on_it
82
87
  begin
83
88
  element.click
84
- rescue Exception => e
85
- webdriver_error(e.class, "type_to_input(#{xpath_name}, #{text_to_send}, #{clear_content}, #{click_on_it}) error in 'element.click' error: #{e}")
89
+ rescue StandardError => e
90
+ webdriver_error(e.class,
91
+ "type_to_input(#{xpath_name}, #{text_to_send}, " \
92
+ "#{clear_content}, #{click_on_it}) " \
93
+ "error in 'element.click' error: #{e}")
86
94
  end
87
95
  sleep 0.2
88
96
  end
@@ -101,7 +101,7 @@ module OnlyofficeWebdriverWrapper
101
101
  # @param [Integer] pixels how much to scroll
102
102
  # @return [void]
103
103
  def scroll_list_by_pixels(list_xpath, pixels)
104
- execute_javascript("$(document.evaluate(\"#{list_xpath.tr('"', "'")}\", document, null, XPathResult.ANY_TYPE, null).iterateNext()).scrollTop(#{pixels})")
104
+ execute_javascript("#{dom_element_by_xpath(list_xpath)}.scrollTop(#{pixels})")
105
105
  end
106
106
 
107
107
  # Open dropdown selector, like 'Color Selector', which has no element id
@@ -148,7 +148,7 @@ module OnlyofficeWebdriverWrapper
148
148
  @driver.find_element(:xpath, xpath_name)
149
149
  true
150
150
  end
151
- rescue Exception
151
+ rescue StandardError
152
152
  false
153
153
  end
154
154
 
@@ -178,7 +178,7 @@ module OnlyofficeWebdriverWrapper
178
178
 
179
179
  begin
180
180
  visible = element.displayed?
181
- rescue Exception => e
181
+ rescue StandardError => e
182
182
  OnlyofficeLoggerHelper.log("Element #{xpath_name} is not visible because of: #{e.message}")
183
183
  visible = false
184
184
  end
@@ -196,16 +196,21 @@ module OnlyofficeWebdriverWrapper
196
196
  return true if current_element.displayed?
197
197
  end
198
198
  false
199
- rescue Exception => e
199
+ rescue StandardError => e
200
200
  webdriver_error("Raise unknown exception: #{e}")
201
201
  end
202
202
 
203
203
  # Get page source
204
204
  # @return [String] all page source
205
- def get_page_source
205
+ def page_source
206
206
  @driver.execute_script('return document.documentElement.innerHTML;')
207
207
  end
208
208
 
209
+ alias get_page_source page_source
210
+
211
+ extend Gem::Deprecate
212
+ deprecate :get_page_source, 'page_source', 2069, 1
213
+
209
214
  # Raise an error, making a screenshot before it
210
215
  # @param [String, Object] exception class to raise
211
216
  # @param [String] error_message to raise
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlyoffice_webdriver_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-08-01 00:00:00.000000000 Z
14
+ date: 2022-08-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: headless
@@ -31,16 +31,16 @@ dependencies:
31
31
  name: onlyoffice_file_helper
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "~>"
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '0'
36
+ version: '2'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: '2'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: onlyoffice_logger_helper
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -59,9 +59,9 @@ dependencies:
59
59
  name: onlyoffice_s3_wrapper
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - "~>"
62
+ - - "<"
63
63
  - !ruby/object:Gem::Version
64
- version: '0'
64
+ version: '2'
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: 0.5.0
@@ -69,9 +69,9 @@ dependencies:
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - "<"
73
73
  - !ruby/object:Gem::Version
74
- version: '0'
74
+ version: '2'
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.5.0
@@ -335,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
335
  - !ruby/object:Gem::Version
336
336
  version: '0'
337
337
  requirements: []
338
- rubygems_version: 3.3.19
338
+ rubygems_version: 3.3.20
339
339
  signing_key:
340
340
  specification_version: 4
341
341
  summary: ONLYOFFICE Webdriver Wrapper Gem