onlyoffice_webdriver_wrapper 1.7.0 → 1.8.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: 6dc61124365371ac4e24646ae4333ae1a590a6e2b0cf8c477c093e335e5d249f
4
- data.tar.gz: cba7d248075d58ebc1249166f684a92ca695b359b3e2e2472e3cc1cbe2ea84da
3
+ metadata.gz: bb66b9cb0b1d1d9c2c1b073c87c8448f219ab606167cf04fc07098fb1b9ab52c
4
+ data.tar.gz: dcc8a129fd4bb6c1bf03cb3c7512e02307b1c468a57692b0cccfaf367013a810
5
5
  SHA512:
6
- metadata.gz: dc5c7c14c73b7ed444ee5f5f1278867199b13b5b2b6a30e9cd0e0018c0456e79d8a029cc7e4a5ce578588e2af4a9f63ad0f890e337338bc9b634d3212931d71a
7
- data.tar.gz: 6283edb3f3b215c3c6aea865e7aaaa9ed2908374a2325d1eb7eda334e72325b07c9aa6a93929b809f895c7e28b9aba1676808ca79dba5329cb8b17a012deef0b
6
+ metadata.gz: 9d291a4d9e4cb76071c29f99ff9e406aed808acadd2da20b8a4809da3104ec6787632a46049af95def7b6ea631a1a345f180e7313297089fc369d13ffa43eefe
7
+ data.tar.gz: 79450930ff1f94e966076dd0ad4c34ea8a88ca746b373dd6505dfc7f1f888b2cd8fb6deac3f2f96d46d763ead26d60dee27bddbe40e1a60540ff0cbc79f89052
@@ -10,6 +10,15 @@ module OnlyofficeWebdriverWrapper
10
10
  @top = top
11
11
  end
12
12
 
13
+ # Compare two dimensions object
14
+ # @param [Object] other object
15
+ # @return [Boolean] result of comparison
16
+ def ==(other)
17
+ return false unless other.respond_to?(:left) && other.respond_to?(:top)
18
+
19
+ @left == other.left && @top == other.top
20
+ end
21
+
13
22
  alias width left
14
23
  alias height top
15
24
  alias x left
@@ -19,5 +28,10 @@ module OnlyofficeWebdriverWrapper
19
28
  def to_s
20
29
  "Dimensions(left: #{@left}, top: #{@top})"
21
30
  end
31
+
32
+ # @return [Dimensions] Center point of current dimension
33
+ def center
34
+ Dimensions.new(@left / 2, @top / 2)
35
+ end
22
36
  end
23
37
  end
@@ -29,7 +29,7 @@ module OnlyofficeWebdriverWrapper
29
29
 
30
30
  # @return [Array<String>] list of formats to save
31
31
  def read_firefox_files_to_save
32
- path_to_file = "#{Dir.pwd}/lib/onlyoffice_webdriver_wrapper/"\
32
+ path_to_file = "#{Dir.pwd}/lib/onlyoffice_webdriver_wrapper/" \
33
33
  'helpers/firefox_helper/save_to_disk_files.list'
34
34
  OnlyofficeFileHelper::FileHelper.read_array_from_file(path_to_file)
35
35
  .join(', ')
@@ -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.7.0'
7
+ STRING = '1.8.0'
8
8
  end
9
9
  end
@@ -71,8 +71,8 @@ module OnlyofficeWebdriverWrapper
71
71
  begin
72
72
  wait.until { get_element(xpath_name) }
73
73
  rescue Selenium::WebDriver::Error::TimeoutError => e
74
- timeout_message = "wait_until_element_present(#{xpath_name}) "\
75
- 'Selenium::WebDriver::Error::TimeoutError: '\
74
+ timeout_message = "wait_until_element_present(#{xpath_name}) " \
75
+ 'Selenium::WebDriver::Error::TimeoutError: ' \
76
76
  "timed out after #{timeout} seconds"
77
77
  webdriver_error(e.class, timeout_message)
78
78
  end
@@ -88,8 +88,8 @@ module OnlyofficeWebdriverWrapper
88
88
  begin
89
89
  wait.until { get_element(xpath_name) ? false : true }
90
90
  rescue Selenium::WebDriver::Error::TimeoutError => e
91
- timeout_message = "wait_until_element_present(#{xpath_name}) "\
92
- 'Selenium::WebDriver::Error::TimeoutError: '\
91
+ timeout_message = "wait_until_element_present(#{xpath_name}) " \
92
+ 'Selenium::WebDriver::Error::TimeoutError: ' \
93
93
  "timed out after #{timeout} seconds"
94
94
  webdriver_error(e.class, timeout_message)
95
95
  end
@@ -33,7 +33,7 @@ module OnlyofficeWebdriverWrapper
33
33
  if @download_directory.start_with?(Dir.tmpdir)
34
34
  FileUtils.remove_dir(@download_directory)
35
35
  else
36
- OnlyofficeLoggerHelper.log("Download directory #{@download_directory} is not at tmp dir. "\
36
+ OnlyofficeLoggerHelper.log("Download directory #{@download_directory} is not at tmp dir. " \
37
37
  'It will be not deleted')
38
38
  end
39
39
  end
@@ -104,8 +104,8 @@ module OnlyofficeWebdriverWrapper
104
104
  # @param [String] xpath of element to remove
105
105
  # @return [String] result of javascript execution
106
106
  def remove_element(xpath)
107
- script = "element = #{dom_element_by_xpath(xpath)};"\
108
- 'if (element !== null) '\
107
+ script = "element = #{dom_element_by_xpath(xpath)};" \
108
+ 'if (element !== null) ' \
109
109
  '{element.parentNode.removeChild(element);};'
110
110
  execute_javascript(script)
111
111
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'fileutils'
3
4
  require 'onlyoffice_s3_wrapper'
4
5
  module OnlyofficeWebdriverWrapper
5
6
  # Working with screenshots
@@ -25,7 +26,7 @@ module OnlyofficeWebdriverWrapper
25
26
  begin
26
27
  get_screenshot(path_to_screenshot)
27
28
  cloud_screenshot = publish_screenshot(path_to_screenshot)
28
- File.delete(path_to_screenshot) if File.exist?(path_to_screenshot)
29
+ FileUtils.rm_rf(path_to_screenshot)
29
30
  OnlyofficeLoggerHelper.log("upload screenshot: #{cloud_screenshot}")
30
31
  return cloud_screenshot
31
32
  rescue Errno::ENOENT => e
@@ -38,9 +38,9 @@ module OnlyofficeWebdriverWrapper
38
38
  begin
39
39
  element.clear
40
40
  rescue Exception => e
41
- webdriver_error(e.class, "Error in element.clear #{e} for "\
42
- "type_to_locator(#{xpath_name}, #{text_to_send}, "\
43
- "#{clear_content}, #{click_on_it}, "\
41
+ webdriver_error(e.class, "Error in element.clear #{e} for " \
42
+ "type_to_locator(#{xpath_name}, #{text_to_send}, " \
43
+ "#{clear_content}, #{click_on_it}, " \
44
44
  "#{by_action}, #{by_element_send_key})")
45
45
  end
46
46
  end
@@ -73,7 +73,7 @@ module OnlyofficeWebdriverWrapper
73
73
  element = get_element(xpath_name)
74
74
  if element.nil?
75
75
  webdriver_error(Selenium::WebDriver::Error::NoSuchElementError,
76
- "type_to_input(#{xpath_name}, #{text_to_send}, "\
76
+ "type_to_input(#{xpath_name}, #{text_to_send}, " \
77
77
  "#{clear_content}, #{click_on_it}): element not found")
78
78
  end
79
79
  element.clear if clear_content
@@ -4,20 +4,20 @@ module OnlyofficeWebdriverWrapper
4
4
  # Module for working with webdriver useragent
5
5
  module WebdriverUserAgentHelper
6
6
  # @return [String] useragent for Android phone browser
7
- USERAGENT_ANDROID_PHONE = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MDB08M) '\
8
- 'AppleWebKit/537.36 (KHTML, like Gecko) '\
7
+ USERAGENT_ANDROID_PHONE = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MDB08M) ' \
8
+ 'AppleWebKit/537.36 (KHTML, like Gecko) ' \
9
9
  'Chrome/51.0.2704.81 Mobile Safari/537.36'
10
10
  # @return [String] useragent for iPhone browser
11
- USERAGENT_IPHONE = 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) '\
12
- 'AppleWebKit/601.1.46 (KHTML, like Gecko) '\
11
+ USERAGENT_IPHONE = 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_2 like Mac OS X) ' \
12
+ 'AppleWebKit/601.1.46 (KHTML, like Gecko) ' \
13
13
  'Version/9.0 Mobile/13F69 Safari/601.1'
14
14
  # @return [String] useragent for iPad Air 2 Safari browser
15
- USERAGENT_IPAD_AIR_2_SAFARI = 'Mozilla/5.0 (iPad; CPU OS 10_0 like Mac OS X) '\
16
- 'AppleWebKit/602.1.50 (KHTML, like Gecko) '\
15
+ USERAGENT_IPAD_AIR_2_SAFARI = 'Mozilla/5.0 (iPad; CPU OS 10_0 like Mac OS X) ' \
16
+ 'AppleWebKit/602.1.50 (KHTML, like Gecko) ' \
17
17
  'Version/10.0 Mobile/14A5346a Safari/602.1'
18
18
  # @return [String] useragent for Nexus 10 Chrome browser
19
- USERAGENT_NEXUS_10_CHROME = 'Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) '\
20
- 'AppleWebKit/537.36 (KHTML, like Gecko) '\
19
+ USERAGENT_NEXUS_10_CHROME = 'Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) ' \
20
+ 'AppleWebKit/537.36 (KHTML, like Gecko) ' \
21
21
  'Chrome/48.0.2564.23 Safari/537.36'
22
22
 
23
23
  # @return [String, nil] user agent string for current device
@@ -119,12 +119,13 @@ module OnlyofficeWebdriverWrapper
119
119
  end
120
120
 
121
121
  # Get index of element by it's text
122
- # @param [String] title to compare text
123
- # @param [Array<Objects>] list_elements to find in which
124
- # @return [Object, nil] nil if nothing found
125
- def get_element_index(title, list_elements)
122
+ # @param [String] text to compare text
123
+ # @param [Array<PageObject::Elements::Element>] list_elements array with
124
+ # PageObject elements to find in
125
+ # @return [Integer, nil] nil if nothing found, index if found
126
+ def get_element_index(text, list_elements)
126
127
  list_elements.each_with_index do |current, i|
127
- return i if get_text(current) == title
128
+ return i if get_text(current) == text
128
129
  end
129
130
  nil
130
131
  end
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.7.0
4
+ version: 1.8.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-06-24 00:00:00.000000000 Z
14
+ date: 2022-07-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: headless
@@ -332,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  - !ruby/object:Gem::Version
333
333
  version: '0'
334
334
  requirements: []
335
- rubygems_version: 3.3.16
335
+ rubygems_version: 3.3.17
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: ONLYOFFICE Webdriver Wrapper Gem