onlyoffice_webdriver_wrapper 0.3.1 → 0.3.2
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: 0044c9d5e8971a853777153b56dabc039847c52a6c5fc980cf8da9f569bd9a27
|
4
|
+
data.tar.gz: 523f06a1503fca9cdcb64972f90801212aad5ad6f128992d047d866dd14b8c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2904eb6b01834f659d2f438b9407935cfb9bae36c8c9b22d8cc4148a84dc7d2ed6478fe6924fa14cc96deb134dd5da7cecd7d2968a84a3d2a76d0cd05d7b422d
|
7
|
+
data.tar.gz: 9908660e5563f7912d52c2770054d5577a2e219323a837aa63ed92314a9764660b02dae4082085785298e43e41455b181faad96c2fb0643e995b9a3b963d3f0f
|
@@ -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/wait_until_methods'
|
10
11
|
require_relative 'webdriver/webdriver_alert_helper'
|
11
12
|
require_relative 'webdriver/webdriver_attributes_helper'
|
12
13
|
require_relative 'webdriver/webdriver_browser_info_helper'
|
@@ -26,6 +27,7 @@ module OnlyofficeWebdriverWrapper
|
|
26
27
|
include ChromeHelper
|
27
28
|
include FirefoxHelper
|
28
29
|
include RubyHelper
|
30
|
+
include WaitUntilMethods
|
29
31
|
include WebdriverAlertHelper
|
30
32
|
include WebdriverAttributesHelper
|
31
33
|
include WebdriverBrowserInfo
|
@@ -37,7 +39,6 @@ module OnlyofficeWebdriverWrapper
|
|
37
39
|
include WebdriverTabHelper
|
38
40
|
include WebdriverUserAgentHelper
|
39
41
|
include WebdriverBrowserLogHelper
|
40
|
-
TIMEOUT_WAIT_ELEMENT = 15
|
41
42
|
TIMEOUT_FILE_DOWNLOAD = 100
|
42
43
|
# @return [Array, String] default switches for chrome
|
43
44
|
attr_accessor :driver
|
@@ -392,24 +393,6 @@ module OnlyofficeWebdriverWrapper
|
|
392
393
|
false
|
393
394
|
end
|
394
395
|
|
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
396
|
def get_element_by_display(xpath_name)
|
414
397
|
@driver.find_elements(:xpath, xpath_name).each do |element|
|
415
398
|
return element if element.displayed?
|
@@ -461,18 +444,6 @@ module OnlyofficeWebdriverWrapper
|
|
461
444
|
end
|
462
445
|
end
|
463
446
|
|
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
447
|
# Check if any element of xpath is displayed
|
477
448
|
# @param xpath_several_elements [String] xpath to check
|
478
449
|
# @return [True, False] result of visibility
|
@@ -574,22 +545,6 @@ module OnlyofficeWebdriverWrapper
|
|
574
545
|
raise exception, "#{error_message}\n\nPage address: #{current_url}\n\nError #{webdriver_screenshot}"
|
575
546
|
end
|
576
547
|
|
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
548
|
def wait_file_for_download(file_name, timeout = TIMEOUT_FILE_DOWNLOAD)
|
594
549
|
full_file_name = "#{@download_directory}/#{file_name}"
|
595
550
|
full_file_name = file_name if file_name[0] == '/'
|
@@ -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
|
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.2
|
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-06-
|
14
|
+
date: 2020-06-30 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/wait_until_methods.rb
|
151
152
|
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_alert_helper.rb
|
152
153
|
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_attributes_helper.rb
|
153
154
|
- lib/onlyoffice_webdriver_wrapper/webdriver/webdriver_browser_info_helper.rb
|