onlyoffice_webdriver_wrapper 0.3.0 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 466fdc464f23a3a828978fcb993dd636767aae148171fc4b6b704ccd6b66ec2a
4
- data.tar.gz: 8a29c9d0a8395a64a5bd5d68e1e3715338b3bd8bf5471cef1c88499dddbfefa4
3
+ metadata.gz: 330c079d2c339d796d82e107ba37334d20240ede30025e32c0d113f910e5b3c2
4
+ data.tar.gz: a26e4e28f96fabfb556ae5cb968591a2fb96096b0d8fc7d8db44f47c3ad68e55
5
5
  SHA512:
6
- metadata.gz: a23012410f76072026df4362ea99acf396600ecd3b9eb8e570cc6862a6d7a96b3a1ea751d047d4606088e0f96d8af45e9d4fdd39c97dae88b207b865aa2486f5
7
- data.tar.gz: 489a793f730ae4376668b2361878ecb6c36fbebeb6c670b99caf1e06d99a57d9af16841612188e628fa3f5764b192bf8fc0b65432252f6184161fb81fa89ef5c
6
+ metadata.gz: 6ecdcce1acc5850b9f8025d4e2b79d00f36fb5347b1e55f2bfda709d44bf337c05c04048989f4ed35fdde5eaa5cf5026a821165a53a8e86f1b73d4fa3c1421dc
7
+ data.tar.gz: d7dffb5e28cba23b06e54e9799c1f533ff244eaa36698b000d744a5965fa795ee64fdac43be21da89555e2eba2f5dcb078997c2b3cee61473e727af80922d98b
@@ -3,6 +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
7
 
7
8
  module OnlyofficeWebdriverWrapper
8
9
  # Class for using headless gem
@@ -0,0 +1,18 @@
1
+ class Headless
2
+ def take_screenshot(file_path, options={})
3
+ using = options.fetch(:using, :imagemagick)
4
+ case using
5
+ when :imagemagick
6
+ CliUtil.ensure_application_exists!('import', "imagemagick is not found on your system. Please install it using sudo apt-get install imagemagick")
7
+ system "#{CliUtil.path_to('import')} -display :#{display} -window root #{file_path}"
8
+ when :xwd
9
+ CliUtil.ensure_application_exists!('xwd', "xwd is not found on your system. Please install it using sudo apt-get install X11-apps")
10
+ system "#{CliUtil.path_to('xwd')} -display localhost:#{display} -silent -root -out #{file_path}"
11
+ when :graphicsmagick, :gm
12
+ CliUtil.ensure_application_exists!('gm', "graphicsmagick is not found on your system. Please install it.")
13
+ system "#{CliUtil.path_to('gm')} import -display localhost:#{display} -window root #{file_path}"
14
+ else
15
+ raise Headless::Exception.new('Unknown :using option value')
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OnlyofficeWebdriverWrapper
4
4
  module Version
5
- STRING = '0.3.0'
5
+ STRING = '0.3.5'
6
6
  end
7
7
  end
@@ -7,6 +7,8 @@ require 'selenium-webdriver'
7
7
  require 'uri'
8
8
  require_relative 'helpers/chrome_helper'
9
9
  require_relative 'helpers/firefox_helper'
10
+ require_relative 'webdriver/click_methods'
11
+ require_relative 'webdriver/wait_until_methods'
10
12
  require_relative 'webdriver/webdriver_alert_helper'
11
13
  require_relative 'webdriver/webdriver_attributes_helper'
12
14
  require_relative 'webdriver/webdriver_browser_info_helper'
@@ -24,8 +26,10 @@ module OnlyofficeWebdriverWrapper
24
26
  # noinspection RubyTooManyMethodsInspection, RubyInstanceMethodNamingConvention, RubyParameterNamingConvention
25
27
  class WebDriver
26
28
  include ChromeHelper
29
+ include ClickMethods
27
30
  include FirefoxHelper
28
31
  include RubyHelper
32
+ include WaitUntilMethods
29
33
  include WebdriverAlertHelper
30
34
  include WebdriverAttributesHelper
31
35
  include WebdriverBrowserInfo
@@ -37,7 +41,6 @@ module OnlyofficeWebdriverWrapper
37
41
  include WebdriverTabHelper
38
42
  include WebdriverUserAgentHelper
39
43
  include WebdriverBrowserLogHelper
40
- TIMEOUT_WAIT_ELEMENT = 15
41
44
  TIMEOUT_FILE_DOWNLOAD = 100
42
45
  # @return [Array, String] default switches for chrome
43
46
  attr_accessor :driver
@@ -123,20 +126,6 @@ module OnlyofficeWebdriverWrapper
123
126
  get_elements(array_elements).map { |current_element| get_text(current_element) }
124
127
  end
125
128
 
126
- def click(element)
127
- element.click
128
- end
129
-
130
- def click_and_wait(element_to_click, element_to_wait)
131
- element_to_click.click
132
- count = 0
133
- while !element_to_wait.present? && count < 30
134
- sleep 1
135
- count += 1
136
- end
137
- webdriver_error("click_and_wait: Wait for element: #{element_to_click} for 30 seconds") if count == 30
138
- end
139
-
140
129
  def select_from_list_elements(value, elements_value)
141
130
  index = get_element_index(value, elements_value)
142
131
  elements_value[index].click
@@ -171,27 +160,6 @@ module OnlyofficeWebdriverWrapper
171
160
  OnlyofficeLoggerHelper.log('Go back to previous page')
172
161
  end
173
162
 
174
- def self.host_name_by_full_url(full_url)
175
- uri = URI(full_url)
176
- uri.port == 80 || uri.port == 443 ? "#{uri.scheme}://#{uri.host}" : "#{uri.scheme}://#{uri.host}:#{uri.port}"
177
- end
178
-
179
- def get_host_name
180
- WebDriver.host_name_by_full_url(get_url)
181
- end
182
-
183
- def remove_event(event_name)
184
- execute_javascript("jQuery(document).unbind('#{event_name}');")
185
- end
186
-
187
- def remove_class_by_jquery(selector, class_name)
188
- execute_javascript("$(#{dom_element_by_xpath(selector)}).removeClass('#{class_name}');")
189
- end
190
-
191
- def add_class_by_jquery(selector, class_name)
192
- execute_javascript("$(#{dom_element_by_xpath(selector)}).addClass('#{class_name}');")
193
- end
194
-
195
163
  # Perform drag'n'drop action in one element (for example on big canvas area)
196
164
  # for drag'n'drop one whole element use 'drag_and_drop_by'
197
165
  # ==== Attributes
@@ -250,119 +218,12 @@ module OnlyofficeWebdriverWrapper
250
218
  end
251
219
  end
252
220
 
253
- # Click on locator
254
- # @param count [Integer] count of clicks
255
- def click_on_locator(xpath_name, by_javascript = false, count: 1)
256
- element = get_element(xpath_name)
257
- return webdriver_error("Element with xpath: #{xpath_name} not found") if element.nil?
258
-
259
- if by_javascript
260
- execute_javascript("document.evaluate(\"#{xpath_name}\", document, null, XPathResult.ANY_TYPE, null).iterateNext().click();")
261
- else
262
- begin
263
- count.times { element.click }
264
- rescue Selenium::WebDriver::Error::ElementNotVisibleError
265
- webdriver_error("Selenium::WebDriver::Error::ElementNotVisibleError: element not visible for xpath: #{xpath_name}")
266
- rescue Exception => e
267
- webdriver_error(e.class, "UnknownError #{e.message} #{xpath_name}")
268
- end
269
- end
270
- end
271
-
272
- def left_mouse_click(xpath, x_coord, y_coord)
273
- @driver.action.move_to(get_element(xpath), x_coord.to_i, y_coord.to_i).click.perform
274
- end
275
-
276
- # Context click on locator
277
- # @param [String] xpath_name name of xpath to click
278
- def context_click_on_locator(xpath_name)
279
- wait_until_element_visible(xpath_name)
280
-
281
- element = @driver.find_element(:xpath, xpath_name)
282
- @driver.action.context_click(element).perform
283
- end
284
-
285
- def right_click(xpath_name)
286
- @driver.action.context_click(@driver.find_element(:xpath, xpath_name)).perform
287
- end
288
-
289
- def click_on_displayed(xpath_name)
290
- element = get_element_by_display(xpath_name)
291
- begin
292
- element.is_a?(Array) ? element.first.click : element.click
293
- rescue Exception => e
294
- webdriver_error("Exception #{e} in click_on_displayed(#{xpath_name})")
295
- end
296
- end
297
-
298
- def click_on_locator_coordinates(xpath_name, right_by, down_by)
299
- wait_until_element_visible(xpath_name)
300
- element = @driver.find_element(:xpath, xpath_name)
301
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).perform
302
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).click.perform
303
- end
304
-
305
- def right_click_on_locator_coordinates(xpath_name, right_by = nil, down_by = nil)
306
- wait_until_element_visible(xpath_name)
307
- element = @driver.find_element(:xpath, xpath_name)
308
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).perform
309
- @driver.action.move_to(element, right_by.to_i, down_by.to_i).context_click.perform
310
- end
311
-
312
- def double_click(xpath_name)
313
- wait_until_element_visible(xpath_name)
314
- @driver.action.move_to(@driver.find_element(:xpath, xpath_name)).double_click.perform
315
- end
316
-
317
- def double_click_on_locator_coordinates(xpath_name, right_by, down_by)
318
- wait_until_element_visible(xpath_name)
319
- @driver.action.move_to(@driver.find_element(:xpath, xpath_name), right_by.to_i, down_by.to_i).double_click.perform
320
- end
321
-
322
221
  def action_on_locator_coordinates(xpath_name, right_by, down_by, action = :click, times = 1)
323
222
  wait_until_element_visible(xpath_name)
324
223
  element = @driver.find_element(:xpath, xpath_name)
325
224
  (0...times).inject(@driver.action.move_to(element, right_by.to_i, down_by.to_i)) { |acc, _elem| acc.send(action) }.perform
326
225
  end
327
226
 
328
- def click_on_one_of_several_by_text(xpath_several_elements, text_to_click)
329
- @driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
330
- next unless text_to_click.to_s == current_element.attribute('innerHTML')
331
-
332
- begin
333
- current_element.click
334
- rescue Exception => e
335
- webdriver_error("Error in click_on_one_of_several_by_text(#{xpath_several_elements}, #{text_to_click}): #{e.message}")
336
- end
337
- return true
338
- end
339
- false
340
- end
341
-
342
- def click_on_one_of_several_by_display(xpath_several_elements)
343
- @driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
344
- if current_element.displayed?
345
- current_element.click
346
- return true
347
- end
348
- end
349
- false
350
- end
351
-
352
- def click_on_one_of_several_by_parameter(xpath_several_elements, parameter_name, parameter_value)
353
- @driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
354
- if current_element.attribute(parameter_name).include? parameter_value
355
- current_element.click
356
- return true
357
- end
358
- end
359
- false
360
- end
361
-
362
- def click_on_one_of_several_xpath_by_number(xpath, number_of_element)
363
- click_on_locator("(#{xpath})[#{number_of_element}]")
364
- end
365
-
366
227
  def move_to_element(element)
367
228
  element = get_element(element) if element.is_a?(String)
368
229
  @driver.action.move_to(element).perform
@@ -392,24 +253,6 @@ module OnlyofficeWebdriverWrapper
392
253
  false
393
254
  end
394
255
 
395
- def wait_until_element_present(xpath_name)
396
- wait = Selenium::WebDriver::Wait.new(timeout: TIMEOUT_WAIT_ELEMENT) # seconds
397
- begin
398
- wait.until { get_element(xpath_name) }
399
- rescue Selenium::WebDriver::Error::TimeOutError
400
- webdriver_error("wait_until_element_present(#{xpath_name}) Selenium::WebDriver::Error::TimeOutError: timed out after 15 seconds")
401
- end
402
- end
403
-
404
- def wait_until_element_disappear(xpath_name)
405
- wait = Selenium::WebDriver::Wait.new(timeout: TIMEOUT_WAIT_ELEMENT) # seconds
406
- begin
407
- wait.until { get_element(xpath_name) ? false : true }
408
- rescue Selenium::WebDriver::Error::TimeOutError
409
- webdriver_error("wait_until_element_present(#{xpath_name}) Selenium::WebDriver::Error::TimeOutError: timed out after 15 seconds")
410
- end
411
- end
412
-
413
256
  def get_element_by_display(xpath_name)
414
257
  @driver.find_elements(:xpath, xpath_name).each do |element|
415
258
  return element if element.displayed?
@@ -461,18 +304,6 @@ module OnlyofficeWebdriverWrapper
461
304
  end
462
305
  end
463
306
 
464
- def wait_until_element_visible(xpath_name, timeout = 15)
465
- wait_until_element_present(xpath_name)
466
- time = 0
467
- while !element_visible?(xpath_name) && time < timeout
468
- sleep(1)
469
- time += 1
470
- end
471
- return unless time >= timeout
472
-
473
- webdriver_error("Element #{xpath_name} not visible for #{timeout} seconds")
474
- end
475
-
476
307
  # Check if any element of xpath is displayed
477
308
  # @param xpath_several_elements [String] xpath to check
478
309
  # @return [True, False] result of visibility
@@ -574,22 +405,6 @@ module OnlyofficeWebdriverWrapper
574
405
  raise exception, "#{error_message}\n\nPage address: #{current_url}\n\nError #{webdriver_screenshot}"
575
406
  end
576
407
 
577
- def wait_until(timeout = ::PageObject.default_page_wait, message = nil, wait_js: true, &block)
578
- tries ||= 3
579
- wait = Object::Selenium::WebDriver::Wait.new(timeout: timeout, message: message)
580
- wait.until(&block)
581
- if wait_js
582
- wait.until { document_ready? }
583
- wait.until { jquery_finished? }
584
- end
585
- rescue Selenium::WebDriver::Error::TimeOutError
586
- webdriver_error("Wait until timeout: #{timeout} seconds in")
587
- rescue Selenium::WebDriver::Error::StaleElementReferenceError
588
- OnlyofficeLoggerHelper.log("Wait until: rescuing from Stale Element error, #{tries} attempts remaining")
589
- retry unless (tries -= 1).zero?
590
- webdriver_error('Wait until: rescuing from Stale Element error failed after 3 tries')
591
- end
592
-
593
408
  def wait_file_for_download(file_name, timeout = TIMEOUT_FILE_DOWNLOAD)
594
409
  full_file_name = "#{@download_directory}/#{file_name}"
595
410
  full_file_name = file_name if file_name[0] == '/'
@@ -603,11 +418,6 @@ module OnlyofficeWebdriverWrapper
603
418
  full_file_name
604
419
  end
605
420
 
606
- def service_unavailable?
607
- source = get_page_source
608
- source.include?('Error 503')
609
- end
610
-
611
421
  # Perform cleanup if something went wrong during tests
612
422
  # @param forced [True, False] should cleanup run in all cases
613
423
  def self.clean_up(forced = false)
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeWebdriverWrapper
4
+ # Method to perform different clicks
5
+ module ClickMethods
6
+ # Click on specified element
7
+ # @param element [Selenium::WebDriver::Element] element to click
8
+ # @return [nil] nothing
9
+ def click(element)
10
+ element.click
11
+ end
12
+
13
+ # Click on locator
14
+ # @param xpath_name [String] xpath to click
15
+ # @param by_javascript [True, False] should be clicked by javascript
16
+ # @param count [Integer] count of clicks
17
+ def click_on_locator(xpath_name, by_javascript = false, count: 1)
18
+ element = get_element(xpath_name)
19
+ return webdriver_error("Element with xpath: #{xpath_name} not found") if element.nil?
20
+
21
+ if by_javascript
22
+ execute_javascript("document.evaluate(\"#{xpath_name}\", document, null, XPathResult.ANY_TYPE, null).iterateNext().click();")
23
+ else
24
+ begin
25
+ count.times { element.click }
26
+ rescue Selenium::WebDriver::Error::ElementNotVisibleError => e
27
+ webdriver_error(e.class, "Selenium::WebDriver::Error::ElementNotVisibleError: element not visible for xpath: #{xpath_name}")
28
+ rescue Exception => e
29
+ webdriver_error(e.class, "UnknownError #{e.message} #{xpath_name}")
30
+ end
31
+ end
32
+ end
33
+
34
+ # Click on one of several which displayed
35
+ # @param xpath_name [String] xpath to find element
36
+ # @return [nil]
37
+ def click_on_displayed(xpath_name)
38
+ element = get_element_by_display(xpath_name)
39
+ begin
40
+ element.is_a?(Array) ? element.first.click : element.click
41
+ rescue Exception => e
42
+ webdriver_error(e.class, "Exception #{e} in click_on_displayed(#{xpath_name})")
43
+ end
44
+ end
45
+
46
+ # Click on locator by coordinates
47
+ # @param xpath_name [String] xpath to click
48
+ # @param right_by [Integer] shift to right
49
+ # @param down_by [Integer] shift to bottom
50
+ # @return [nil]
51
+ def click_on_locator_coordinates(xpath_name, right_by, down_by)
52
+ wait_until_element_visible(xpath_name)
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
56
+ end
57
+
58
+ # Click on one of several which displayed
59
+ # @param xpath_several_elements [String] xpath to find element
60
+ # @return [True, False] true if click successful, false if not found
61
+ def click_on_one_of_several_by_display(xpath_several_elements)
62
+ @driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
63
+ if current_element.displayed?
64
+ current_element.click
65
+ return true
66
+ end
67
+ end
68
+ false
69
+ end
70
+
71
+ # Click on one of several xpath filtered by parameter and value
72
+ # @param xpath_several_elements [String] xpath to select
73
+ # @param parameter_name [String] parameter name
74
+ # @param parameter_value [String] parameter value
75
+ # @return [True, False] true if click successful, false if not found
76
+ def click_on_one_of_several_by_parameter(xpath_several_elements, parameter_name, parameter_value)
77
+ @driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
78
+ if current_element.attribute(parameter_name).include? parameter_value
79
+ current_element.click
80
+ return true
81
+ end
82
+ end
83
+ false
84
+ end
85
+
86
+ # Perform right click on xpath
87
+ # @param xpath_name [String] xpath to click
88
+ # @return [nil]
89
+ def right_click(xpath_name)
90
+ wait_until_element_visible(xpath_name)
91
+
92
+ @driver.action.context_click(@driver.find_element(:xpath, xpath_name)).perform
93
+ end
94
+
95
+ # Perform right click on locator with specified coordinates
96
+ # @param xpath_name [String] xpath to click
97
+ # @param right_by [Integer] shift to right
98
+ # @param down_by [Integer] shift to bottom
99
+ # @return [nil]
100
+ def right_click_on_locator_coordinates(xpath_name, right_by = nil, down_by = nil)
101
+ wait_until_element_visible(xpath_name)
102
+ 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
105
+ end
106
+
107
+ # Perform double_click on element
108
+ # @param xpath_name [String] xpath to click
109
+ # @return [nil]
110
+ def double_click(xpath_name)
111
+ wait_until_element_visible(xpath_name)
112
+ @driver.action.move_to(@driver.find_element(:xpath, xpath_name)).double_click.perform
113
+ end
114
+
115
+ # Perform double_click on specified coordinates
116
+ # @param xpath_name [String] xpath to click
117
+ # @param right_by [Integer] shift to right
118
+ # @param down_by [Integer] shift to bottom
119
+ # @return [nil]
120
+ def double_click_on_locator_coordinates(xpath_name, right_by, down_by)
121
+ wait_until_element_visible(xpath_name)
122
+ @driver.action.move_to(@driver.find_element(:xpath, xpath_name), right_by.to_i, down_by.to_i).double_click.perform
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeWebdriverWrapper
4
+ # Method to different wait_until methods
5
+ module WaitUntilMethods
6
+ # @return [Integer] default timeout for wait element
7
+ TIMEOUT_WAIT_ELEMENT = 15
8
+
9
+ def wait_until(timeout = ::PageObject.default_page_wait, message = nil, wait_js: true, &block)
10
+ tries ||= 3
11
+ wait = Object::Selenium::WebDriver::Wait.new(timeout: timeout, message: message)
12
+ wait.until(&block)
13
+ if wait_js
14
+ wait.until { document_ready? }
15
+ wait.until { jquery_finished? }
16
+ end
17
+ rescue Selenium::WebDriver::Error::TimeOutError
18
+ webdriver_error("Wait until timeout: #{timeout} seconds in")
19
+ rescue Selenium::WebDriver::Error::StaleElementReferenceError
20
+ OnlyofficeLoggerHelper.log("Wait until: rescuing from Stale Element error, #{tries} attempts remaining")
21
+ retry unless (tries -= 1).zero?
22
+ webdriver_error('Wait until: rescuing from Stale Element error failed after 3 tries')
23
+ end
24
+
25
+ def wait_until_element_visible(xpath_name, timeout = 15)
26
+ wait_until_element_present(xpath_name)
27
+ time = 0
28
+ while !element_visible?(xpath_name) && time < timeout
29
+ sleep(1)
30
+ time += 1
31
+ end
32
+ return unless time >= timeout
33
+
34
+ webdriver_error("Element #{xpath_name} not visible for #{timeout} seconds")
35
+ end
36
+
37
+ # Wait until some element present
38
+ # If timeout exceeded - raise an error
39
+ # @param xpath_name [String] xpath of element
40
+ # @param timeout [Integer] timeout to wait
41
+ # @return [Void]
42
+ def wait_until_element_present(xpath_name, timeout: TIMEOUT_WAIT_ELEMENT)
43
+ wait = Selenium::WebDriver::Wait.new(timeout: timeout) # seconds
44
+ begin
45
+ wait.until { get_element(xpath_name) }
46
+ rescue Selenium::WebDriver::Error::TimeOutError => e
47
+ timeout_message = "wait_until_element_present(#{xpath_name}) "\
48
+ 'Selenium::WebDriver::Error::TimeOutError: '\
49
+ "timed out after #{timeout} seconds"
50
+ webdriver_error(e.class, timeout_message)
51
+ end
52
+ end
53
+
54
+ # Wait until some element disappear
55
+ # If timeout exceeded - raise an error
56
+ # @param xpath_name [String] xpath of element
57
+ # @param timeout [Integer] timeout to wait
58
+ # @return [Void]
59
+ def wait_until_element_disappear(xpath_name, timeout: TIMEOUT_WAIT_ELEMENT)
60
+ wait = Selenium::WebDriver::Wait.new(timeout: timeout) # seconds
61
+ begin
62
+ wait.until { get_element(xpath_name) ? false : true }
63
+ rescue Selenium::WebDriver::Error::TimeOutError => e
64
+ timeout_message = "wait_until_element_present(#{xpath_name}) "\
65
+ 'Selenium::WebDriver::Error::TimeOutError: '\
66
+ "timed out after #{timeout} seconds"
67
+ webdriver_error(e.class, timeout_message)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -10,26 +10,23 @@ module OnlyofficeWebdriverWrapper
10
10
  nil
11
11
  end
12
12
 
13
- def set_style_parameter(xpath, attribute, attribute_value)
14
- execute_javascript("document.evaluate(\"#{xpath.tr('"', "'")}\",document, null, XPathResult.ANY_TYPE, null ).iterateNext()." \
15
- "style.#{attribute}=\"#{attribute_value}\"")
16
- end
17
-
13
+ # Set style attribute value of element
14
+ # @param xpath [String] xpath to set
15
+ # @param attribute [String] style param to set
16
+ # @param attribute_value [String] attribute value to set
17
+ # @return [String] result of execution
18
18
  def set_style_attribute(xpath, attribute, attribute_value)
19
- execute_javascript("document.evaluate('#{xpath}',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)." \
20
- "singleNodeValue.style.#{attribute}=\"#{attribute_value}\"")
19
+ execute_javascript("#{dom_element_by_xpath(xpath)}.style.#{attribute}=\"#{attribute_value}\"")
21
20
  end
22
21
 
22
+ alias set_style_parameter set_style_attribute
23
+
23
24
  def set_style_show_by_xpath(xpath, move_to_center = false)
24
- xpath = xpath.tr("'", '"')
25
- execute_javascript('document.evaluate( \'' + xpath.to_s +
26
- '\' ,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.style.display = "block";')
25
+ execute_javascript("#{dom_element_by_xpath(xpath)}.style.display = 'block';")
27
26
  return unless move_to_center
28
27
 
29
- execute_javascript('document.evaluate( \'' + xpath.to_s +
30
- '\' ,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.style.left = "410px";')
31
- execute_javascript('document.evaluate( \'' + xpath.to_s +
32
- '\' ,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue.style.top = "260px";')
28
+ execute_javascript("#{dom_element_by_xpath(xpath)}.style.left = '410px';")
29
+ execute_javascript("#{dom_element_by_xpath(xpath)}.style.top = '260px';")
33
30
  end
34
31
  end
35
32
  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: 0.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -11,22 +11,22 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-05-22 00:00:00.000000000 Z
14
+ date: 2020-07-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: headless
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: '2'
22
+ version: 2.3.1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: '2'
29
+ version: 2.3.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: onlyoffice_file_helper
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -141,12 +141,15 @@ files:
141
141
  - lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper.rb
142
142
  - lib/onlyoffice_webdriver_wrapper/helpers/firefox_helper/save_to_disk_files.list
143
143
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper.rb
144
+ - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/headless_screenshot_patch.rb
144
145
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/real_display_tools.rb
145
146
  - lib/onlyoffice_webdriver_wrapper/helpers/headless_helper/ruby_helper.rb
146
147
  - lib/onlyoffice_webdriver_wrapper/helpers/os_helper.rb
147
148
  - lib/onlyoffice_webdriver_wrapper/name.rb
148
149
  - lib/onlyoffice_webdriver_wrapper/version.rb
149
150
  - lib/onlyoffice_webdriver_wrapper/webdriver.rb
151
+ - lib/onlyoffice_webdriver_wrapper/webdriver/click_methods.rb
152
+ - lib/onlyoffice_webdriver_wrapper/webdriver/wait_until_methods.rb
150
153
  - lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb
151
154
  - lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_attributes_helper.rb
152
155
  - lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_browser_info_helper.rb
@@ -183,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
186
  - !ruby/object:Gem::Version
184
187
  version: '0'
185
188
  requirements: []
186
- rubygems_version: 3.1.2
189
+ rubygems_version: 3.1.4
187
190
  signing_key:
188
191
  specification_version: 4
189
192
  summary: ONLYOFFICE Webdriver Wrapper Gem