onlyoffice_webdriver_wrapper 1.6.0 → 1.7.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: 29b6744e1acea477bcbfce6af74b2eaab02864d6985be19be496ab26c7a66208
4
- data.tar.gz: 7c2c0b68f14012ccb7f95f3a6f2d7698f12e83a8f06cdd0f48382037cdf33d9c
3
+ metadata.gz: 6dc61124365371ac4e24646ae4333ae1a590a6e2b0cf8c477c093e335e5d249f
4
+ data.tar.gz: cba7d248075d58ebc1249166f684a92ca695b359b3e2e2472e3cc1cbe2ea84da
5
5
  SHA512:
6
- metadata.gz: 06ab15b74f6d81bdcb0fda5b6893465cff70499ab72f68d3483b4aeec91d8abf7f4ae653a650b8b8f5ac7d69d2e75b5c78017d45f2ca795110b40920725fe1c5
7
- data.tar.gz: 55c083c94d1d1ead6acccb73244131670a0796cb2927424c123b557aee2c67e00b4e5f5266ae16657c1250e89fe243dd6ccf36638fbdb938f950fe447e472c73
6
+ metadata.gz: dc5c7c14c73b7ed444ee5f5f1278867199b13b5b2b6a30e9cd0e0018c0456e79d8a029cc7e4a5ce578588e2af4a9f63ad0f890e337338bc9b634d3212931d71a
7
+ data.tar.gz: 6283edb3f3b215c3c6aea865e7aaaa9ed2908374a2325d1eb7eda334e72325b07c9aa6a93929b809f895c7e28b9aba1676808ca79dba5329cb8b17a012deef0b
@@ -21,3 +21,26 @@ class Headless
21
21
  end
22
22
  end
23
23
  end
24
+
25
+ # Until https://github.com/leonid-shevtsov/headless/pull/106
26
+ # is released in stable version
27
+ class Headless
28
+ # Class for handling video records
29
+ class VideoRecorder
30
+ # Stop recording and save it
31
+ # @param [String] path to save
32
+ # @retunr [nil, String] path to result file or nil if error
33
+ def stop_and_save(path)
34
+ CliUtil.kill_process(@pid_file_path, :wait => true)
35
+ if File.exist? @tmp_file_path
36
+ begin
37
+ FileUtils.mkdir_p(File.dirname(path))
38
+ FileUtils.mv(@tmp_file_path, path)
39
+ rescue Errno::EINVAL
40
+ nil
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -3,7 +3,7 @@
3
3
  require_relative 'headless_helper/real_display_tools'
4
4
  require_relative 'headless_helper/ruby_helper'
5
5
  require 'headless'
6
- require_relative 'headless_helper/headless_screenshot_patch'
6
+ require_relative 'headless_helper/headless_patch'
7
7
  require_relative 'headless_helper/headless_video_recorder'
8
8
 
9
9
  module OnlyofficeWebdriverWrapper
@@ -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.6.0'
7
+ STRING = '1.7.0'
8
8
  end
9
9
  end
@@ -51,8 +51,9 @@ module OnlyofficeWebdriverWrapper
51
51
  def click_on_locator_coordinates(xpath_name, right_by, down_by)
52
52
  wait_until_element_visible(xpath_name)
53
53
  element = @driver.find_element(:xpath, xpath_name)
54
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).perform
55
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).click.perform
54
+ shift_to_zero = move_to_shift_to_top_left(xpath_name)
55
+ @driver.action.move_to(element, right_by.to_i - shift_to_zero.x, down_by.to_i - shift_to_zero.y).perform
56
+ @driver.action.move_to(element, right_by.to_i - shift_to_zero.x, down_by.to_i - shift_to_zero.y).click.perform
56
57
  end
57
58
 
58
59
  # Click on one of several which displayed
@@ -100,8 +101,9 @@ module OnlyofficeWebdriverWrapper
100
101
  def right_click_on_locator_coordinates(xpath_name, right_by = nil, down_by = nil)
101
102
  wait_until_element_visible(xpath_name)
102
103
  element = @driver.find_element(:xpath, xpath_name)
103
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).perform
104
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).context_click.perform
104
+ shift_to_zero = move_to_shift_to_top_left(xpath_name)
105
+ @driver.action.move_to(element, right_by.to_i - shift_to_zero.x, down_by.to_i - shift_to_zero.y).perform
106
+ @driver.action.move_to(element, right_by.to_i - shift_to_zero.x, down_by.to_i - shift_to_zero.y).context_click.perform
105
107
  end
106
108
 
107
109
  # Perform double_click on element
@@ -15,9 +15,10 @@ module OnlyofficeWebdriverWrapper
15
15
  # * +mouse_release+ - release mouse after move
16
16
  def drag_and_drop(xpath, x1, y1, x2, y2, mouse_release: true)
17
17
  canvas = get_element(xpath)
18
-
18
+ shift_to_zero = move_to_shift_to_top_left(xpath)
19
19
  move_action = @driver.action
20
- .move_to(canvas, x1.to_i, y1.to_i)
20
+ .move_to(canvas, x1.to_i - shift_to_zero.x,
21
+ y1.to_i - shift_to_zero.y)
21
22
  .click_and_hold
22
23
  .move_by(x2, y2)
23
24
  move_action = move_action.release if mouse_release
@@ -33,15 +34,10 @@ module OnlyofficeWebdriverWrapper
33
34
  # * +right_by+ - shift vector x coordinate
34
35
  # * +down_by+ - shift vector y coordinate
35
36
  def drag_and_drop_by(source, right_by, down_by = 0)
36
- @driver.action.drag_and_drop_by(get_element(source), right_by, down_by).perform
37
- end
38
-
39
- # Move cursor to element
40
- # @param [String, Selenium::WebDriver::Element] element xpath or webdriver element
41
- # @return [nil]
42
- def move_to_element(element)
43
- element = get_element(element) if element.is_a?(String)
44
- @driver.action.move_to(element).perform
37
+ shift_to_zero = move_to_shift_to_top_left(source)
38
+ @driver.action.drag_and_drop_by(get_element(source),
39
+ right_by - shift_to_zero.x,
40
+ down_by - shift_to_zero.y).perform
45
41
  end
46
42
 
47
43
  # Move cursor to element
@@ -60,7 +56,22 @@ module OnlyofficeWebdriverWrapper
60
56
  # @return [nil]
61
57
  def mouse_over(xpath_name, x_coordinate = 0, y_coordinate = 0)
62
58
  wait_until_element_present(xpath_name)
63
- @driver.action.move_to(@driver.find_element(:xpath, xpath_name), x_coordinate.to_i, y_coordinate.to_i).perform
59
+ shift_to_zero = move_to_shift_to_top_left(xpath_name)
60
+ @driver.action.move_to(@driver.find_element(:xpath, xpath_name),
61
+ x_coordinate.to_i - shift_to_zero.x,
62
+ y_coordinate.to_i - shift_to_zero.y).perform
63
+ end
64
+
65
+ # Since v4.3.0 of `webdriver` gem `move_to` method is moving
66
+ # from the center of the element
67
+ # Add additional negative shift if this version is used
68
+ def move_to_shift_to_top_left(xpath)
69
+ if Gem.loaded_specs['selenium-webdriver'].version >= Gem::Version.new('4.3.0')
70
+ element_size = element_size_by_js(xpath)
71
+ Dimensions.new(element_size.x / 2, element_size.y / 2)
72
+ else
73
+ Dimensions.new(0, 0)
74
+ end
64
75
  end
65
76
  end
66
77
  end
@@ -22,16 +22,17 @@ module OnlyofficeWebdriverWrapper
22
22
  end
23
23
 
24
24
  # Switch to popup window
25
+ # @param popup_appear_timeout [Integer] how much time to wait for popup window
25
26
  # @param after_switch_timeout [Integer] wait after switch to window
26
27
  # non-zero to workaround bug with page load hanging up after switch
27
28
  # @return [void]
28
- def switch_to_popup(after_switch_timeout: 3)
29
+ def switch_to_popup(after_switch_timeout: 3, popup_appear_timeout: 30)
29
30
  counter = 0
30
- while tab_count < 2 && counter < 30
31
+ while tab_count < 2 && counter < popup_appear_timeout
31
32
  sleep 1
32
33
  counter += 1
33
34
  end
34
- webdriver_error('switch_to_popup: Popup window not found') if counter >= 30
35
+ webdriver_error('switch_to_popup: Popup window not found') if counter >= popup_appear_timeout
35
36
  list_of_handlers = @driver.window_handles
36
37
  last_window_handler = list_of_handlers.last
37
38
  @driver.switch_to.window(last_window_handler)
@@ -168,7 +168,8 @@ module OnlyofficeWebdriverWrapper
168
168
  set_style_attribute("#{xpath_name}/button", 'display', 'inline-block')
169
169
  set_style_attribute(xpath_name, 'display', 'block')
170
170
  else
171
- @driver.action.move_to(element, horizontal_shift, vertical_shift).click.perform
171
+ shift_to_zero = move_to_shift_to_top_left(xpath_name)
172
+ @driver.action.move_to(element, horizontal_shift - shift_to_zero.x, vertical_shift - shift_to_zero.y).click.perform
172
173
  end
173
174
  end
174
175
 
@@ -182,7 +183,10 @@ module OnlyofficeWebdriverWrapper
182
183
  def action_on_locator_coordinates(xpath_name, right_by, down_by, action = :click, times = 1)
183
184
  wait_until_element_visible(xpath_name)
184
185
  element = @driver.find_element(:xpath, xpath_name)
185
- (0...times).inject(@driver.action.move_to(element, right_by.to_i, down_by.to_i)) { |acc, _elem| acc.send(action) }.perform
186
+ shift_to_zero = move_to_shift_to_top_left(xpath_name)
187
+ (0...times).inject(@driver.action.move_to(element,
188
+ right_by.to_i - shift_to_zero.x,
189
+ down_by.to_i - shift_to_zero.y)) { |acc, _elem| acc.send(action) }.perform
186
190
  end
187
191
 
188
192
  # Check if element present on page
@@ -254,7 +258,8 @@ module OnlyofficeWebdriverWrapper
254
258
 
255
259
  begin
256
260
  visible = element.displayed?
257
- rescue Exception
261
+ rescue Exception => e
262
+ OnlyofficeLoggerHelper.log("Element #{xpath_name} is not visible because of: #{e.message}")
258
263
  visible = false
259
264
  end
260
265
  visible
@@ -295,7 +300,7 @@ module OnlyofficeWebdriverWrapper
295
300
  # @param [String] xpath_several_elements to find objects
296
301
  # @return [Array<String>] text of those elements
297
302
  def get_text_of_several_elements(xpath_several_elements)
298
- @driver.find_elements(:xpath, xpath_several_elements).map { |element| element.text unless element.text == '' }.compact
303
+ @driver.find_elements(:xpath, xpath_several_elements).filter_map { |element| element.text unless element.text == '' }
299
304
  end
300
305
 
301
306
  # Select value of combo box
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.6.0
4
+ version: 1.7.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-05-25 00:00:00.000000000 Z
14
+ date: 2022-06-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: headless
@@ -275,14 +275,14 @@ files:
275
275
  - lib/onlyoffice_webdriver_wrapper/helpers/bin/geckodriver
276
276
  - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper.rb
277
277
  - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chrome_version_helper.rb
278
- - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chromedriver_bin/chromedriver_linux_100
279
278
  - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chromedriver_bin/chromedriver_linux_101
280
279
  - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chromedriver_bin/chromedriver_linux_102
280
+ - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chromedriver_bin/chromedriver_linux_103
281
281
  - lib/onlyoffice_webdriver_wrapper/helpers/chrome_helper/chromedriver_bin/chromedriver_mac
282
282
  - lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper.rb
283
283
  - lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper/save_to_disk_files.list
284
284
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper.rb
285
- - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_screenshot_patch.rb
285
+ - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_patch.rb
286
286
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_video_recorder.rb
287
287
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/real_display_tools.rb
288
288
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/ruby_helper.rb
@@ -325,14 +325,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
325
325
  requirements:
326
326
  - - ">="
327
327
  - !ruby/object:Gem::Version
328
- version: '2.6'
328
+ version: '2.7'
329
329
  required_rubygems_version: !ruby/object:Gem::Requirement
330
330
  requirements:
331
331
  - - ">="
332
332
  - !ruby/object:Gem::Version
333
333
  version: '0'
334
334
  requirements: []
335
- rubygems_version: 3.3.12
335
+ rubygems_version: 3.3.16
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: ONLYOFFICE Webdriver Wrapper Gem