onlyoffice_webdriver_wrapper 0.3.2 → 0.3.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f98ac75fa3bf47f7ada257812f98097c9dc65d183ca4f6da5d5b42b2c410d84d
|
4
|
+
data.tar.gz: 3cbcf38f96e27e4f8f9a71a08961b83a450c3d3da11fe970417e6ddc81bb6a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64f12991857161f2234fa7f0b3d22b1da3fdb7c0b8af45fb6a8554cc53fea1a9278635429a2fc3ea8395f64bd58a785c65ce9ea9677e5b9881c7c040cc9ffd6c
|
7
|
+
data.tar.gz: 6dc715859f6b85af142b13fa96d54ab0ca13bd221116076ad3a79eeeb599d2bb6a2c6bac613c4c4097b7f678a2f0441528a8c76532efe6ceb4a55fb006e048c1
|
@@ -7,6 +7,7 @@ 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'
|
10
11
|
require_relative 'webdriver/wait_until_methods'
|
11
12
|
require_relative 'webdriver/webdriver_alert_helper'
|
12
13
|
require_relative 'webdriver/webdriver_attributes_helper'
|
@@ -25,6 +26,7 @@ module OnlyofficeWebdriverWrapper
|
|
25
26
|
# noinspection RubyTooManyMethodsInspection, RubyInstanceMethodNamingConvention, RubyParameterNamingConvention
|
26
27
|
class WebDriver
|
27
28
|
include ChromeHelper
|
29
|
+
include ClickMethods
|
28
30
|
include FirefoxHelper
|
29
31
|
include RubyHelper
|
30
32
|
include WaitUntilMethods
|
@@ -124,20 +126,6 @@ module OnlyofficeWebdriverWrapper
|
|
124
126
|
get_elements(array_elements).map { |current_element| get_text(current_element) }
|
125
127
|
end
|
126
128
|
|
127
|
-
def click(element)
|
128
|
-
element.click
|
129
|
-
end
|
130
|
-
|
131
|
-
def click_and_wait(element_to_click, element_to_wait)
|
132
|
-
element_to_click.click
|
133
|
-
count = 0
|
134
|
-
while !element_to_wait.present? && count < 30
|
135
|
-
sleep 1
|
136
|
-
count += 1
|
137
|
-
end
|
138
|
-
webdriver_error("click_and_wait: Wait for element: #{element_to_click} for 30 seconds") if count == 30
|
139
|
-
end
|
140
|
-
|
141
129
|
def select_from_list_elements(value, elements_value)
|
142
130
|
index = get_element_index(value, elements_value)
|
143
131
|
elements_value[index].click
|
@@ -251,119 +239,12 @@ module OnlyofficeWebdriverWrapper
|
|
251
239
|
end
|
252
240
|
end
|
253
241
|
|
254
|
-
# Click on locator
|
255
|
-
# @param count [Integer] count of clicks
|
256
|
-
def click_on_locator(xpath_name, by_javascript = false, count: 1)
|
257
|
-
element = get_element(xpath_name)
|
258
|
-
return webdriver_error("Element with xpath: #{xpath_name} not found") if element.nil?
|
259
|
-
|
260
|
-
if by_javascript
|
261
|
-
execute_javascript("document.evaluate(\"#{xpath_name}\", document, null, XPathResult.ANY_TYPE, null).iterateNext().click();")
|
262
|
-
else
|
263
|
-
begin
|
264
|
-
count.times { element.click }
|
265
|
-
rescue Selenium::WebDriver::Error::ElementNotVisibleError
|
266
|
-
webdriver_error("Selenium::WebDriver::Error::ElementNotVisibleError: element not visible for xpath: #{xpath_name}")
|
267
|
-
rescue Exception => e
|
268
|
-
webdriver_error(e.class, "UnknownError #{e.message} #{xpath_name}")
|
269
|
-
end
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
def left_mouse_click(xpath, x_coord, y_coord)
|
274
|
-
@driver.action.move_to(get_element(xpath), x_coord.to_i, y_coord.to_i).click.perform
|
275
|
-
end
|
276
|
-
|
277
|
-
# Context click on locator
|
278
|
-
# @param [String] xpath_name name of xpath to click
|
279
|
-
def context_click_on_locator(xpath_name)
|
280
|
-
wait_until_element_visible(xpath_name)
|
281
|
-
|
282
|
-
element = @driver.find_element(:xpath, xpath_name)
|
283
|
-
@driver.action.context_click(element).perform
|
284
|
-
end
|
285
|
-
|
286
|
-
def right_click(xpath_name)
|
287
|
-
@driver.action.context_click(@driver.find_element(:xpath, xpath_name)).perform
|
288
|
-
end
|
289
|
-
|
290
|
-
def click_on_displayed(xpath_name)
|
291
|
-
element = get_element_by_display(xpath_name)
|
292
|
-
begin
|
293
|
-
element.is_a?(Array) ? element.first.click : element.click
|
294
|
-
rescue Exception => e
|
295
|
-
webdriver_error("Exception #{e} in click_on_displayed(#{xpath_name})")
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
def click_on_locator_coordinates(xpath_name, right_by, down_by)
|
300
|
-
wait_until_element_visible(xpath_name)
|
301
|
-
element = @driver.find_element(:xpath, xpath_name)
|
302
|
-
@driver.action.move_to(element, right_by.to_i, down_by.to_i).perform
|
303
|
-
@driver.action.move_to(element, right_by.to_i, down_by.to_i).click.perform
|
304
|
-
end
|
305
|
-
|
306
|
-
def right_click_on_locator_coordinates(xpath_name, right_by = nil, down_by = nil)
|
307
|
-
wait_until_element_visible(xpath_name)
|
308
|
-
element = @driver.find_element(:xpath, xpath_name)
|
309
|
-
@driver.action.move_to(element, right_by.to_i, down_by.to_i).perform
|
310
|
-
@driver.action.move_to(element, right_by.to_i, down_by.to_i).context_click.perform
|
311
|
-
end
|
312
|
-
|
313
|
-
def double_click(xpath_name)
|
314
|
-
wait_until_element_visible(xpath_name)
|
315
|
-
@driver.action.move_to(@driver.find_element(:xpath, xpath_name)).double_click.perform
|
316
|
-
end
|
317
|
-
|
318
|
-
def double_click_on_locator_coordinates(xpath_name, right_by, down_by)
|
319
|
-
wait_until_element_visible(xpath_name)
|
320
|
-
@driver.action.move_to(@driver.find_element(:xpath, xpath_name), right_by.to_i, down_by.to_i).double_click.perform
|
321
|
-
end
|
322
|
-
|
323
242
|
def action_on_locator_coordinates(xpath_name, right_by, down_by, action = :click, times = 1)
|
324
243
|
wait_until_element_visible(xpath_name)
|
325
244
|
element = @driver.find_element(:xpath, xpath_name)
|
326
245
|
(0...times).inject(@driver.action.move_to(element, right_by.to_i, down_by.to_i)) { |acc, _elem| acc.send(action) }.perform
|
327
246
|
end
|
328
247
|
|
329
|
-
def click_on_one_of_several_by_text(xpath_several_elements, text_to_click)
|
330
|
-
@driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
|
331
|
-
next unless text_to_click.to_s == current_element.attribute('innerHTML')
|
332
|
-
|
333
|
-
begin
|
334
|
-
current_element.click
|
335
|
-
rescue Exception => e
|
336
|
-
webdriver_error("Error in click_on_one_of_several_by_text(#{xpath_several_elements}, #{text_to_click}): #{e.message}")
|
337
|
-
end
|
338
|
-
return true
|
339
|
-
end
|
340
|
-
false
|
341
|
-
end
|
342
|
-
|
343
|
-
def click_on_one_of_several_by_display(xpath_several_elements)
|
344
|
-
@driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
|
345
|
-
if current_element.displayed?
|
346
|
-
current_element.click
|
347
|
-
return true
|
348
|
-
end
|
349
|
-
end
|
350
|
-
false
|
351
|
-
end
|
352
|
-
|
353
|
-
def click_on_one_of_several_by_parameter(xpath_several_elements, parameter_name, parameter_value)
|
354
|
-
@driver.find_elements(:xpath, xpath_several_elements).each do |current_element|
|
355
|
-
if current_element.attribute(parameter_name).include? parameter_value
|
356
|
-
current_element.click
|
357
|
-
return true
|
358
|
-
end
|
359
|
-
end
|
360
|
-
false
|
361
|
-
end
|
362
|
-
|
363
|
-
def click_on_one_of_several_xpath_by_number(xpath, number_of_element)
|
364
|
-
click_on_locator("(#{xpath})[#{number_of_element}]")
|
365
|
-
end
|
366
|
-
|
367
248
|
def move_to_element(element)
|
368
249
|
element = get_element(element) if element.is_a?(String)
|
369
250
|
@driver.action.move_to(element).perform
|
@@ -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
|
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.
|
4
|
+
version: 0.3.3
|
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: 2020-
|
14
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: headless
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/onlyoffice_webdriver_wrapper/name.rb
|
149
149
|
- lib/onlyoffice_webdriver_wrapper/version.rb
|
150
150
|
- lib/onlyoffice_webdriver_wrapper/webdriver.rb
|
151
|
+
- lib/onlyoffice_webdriver_wrapper/webdriver/click_methods.rb
|
151
152
|
- lib/onlyoffice_webdriver_wrapper/webdriver/wait_until_methods.rb
|
152
153
|
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb
|
153
154
|
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_attributes_helper.rb
|
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
186
|
- !ruby/object:Gem::Version
|
186
187
|
version: '0'
|
187
188
|
requirements: []
|
188
|
-
rubygems_version: 3.1.
|
189
|
+
rubygems_version: 3.1.4
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: ONLYOFFICE Webdriver Wrapper Gem
|