watir-dom-wait 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/watir/dom/elements/element.rb +14 -8
- data/lib/watir/dom/extensions/js/waitForDom.js +1 -1
- data/lib/watir-dom-wait.rb +14 -0
- data/spec/spec_helper.rb +0 -2
- data/spec/watir-dom-wait/element_spec.rb +26 -21
- data/watir-dom-wait.gemspec +2 -5
- metadata +8 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0b066817603bde9fef59bcc7274963517dc2291e06fdae4d5543c333a6588e24
|
4
|
+
data.tar.gz: 98adfb587832f044bf09b83d0910699ae15c7601242f5984af0faa3f4191bade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac4f364fa642af309078537e8ad370733668b03f34dbdb98d996d9e8314c5a58407aa75abce0e5bb24abf4ed90292e8f57f472290af52ca0796cdf865e95a3b2
|
7
|
+
data.tar.gz: 882b8fff9e41ad4bc147a52f589935801f914ab3d02d217df9fb7c5b1cf9235e5efa4c1c56779fd5dd06b01d79f8924db3ff109c7e9474d4a469334697d43e23
|
@@ -17,14 +17,20 @@ module Watir
|
|
17
17
|
#
|
18
18
|
|
19
19
|
def dom_changed?(delay: 1.1)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
element_call do
|
21
|
+
begin
|
22
|
+
script_timeout = driver.manage.timeouts.script_timeout
|
23
|
+
driver.manage.timeouts.script_timeout = delay + Watir::DOM::Wait.minimum_script_timeout
|
24
|
+
driver.execute_async_script(DOM_WAIT_JS, wd, delay)
|
25
|
+
rescue Selenium::WebDriver::Error::JavascriptError => error
|
26
|
+
# sometimes we start script execution before new page is loaded and
|
27
|
+
# in rare cases ChromeDriver throws this error, we just swallow it and retry
|
28
|
+
retry if error.message.include?('document unloaded while waiting for result')
|
29
|
+
raise
|
30
|
+
ensure
|
31
|
+
driver.manage.timeouts.script_timeout = script_timeout
|
32
|
+
end
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end # Element
|
30
36
|
end # Watir
|
data/lib/watir-dom-wait.rb
CHANGED
@@ -1,2 +1,16 @@
|
|
1
1
|
require 'watir'
|
2
2
|
require 'watir/dom/elements/element'
|
3
|
+
|
4
|
+
module Watir
|
5
|
+
module DOM
|
6
|
+
module Wait
|
7
|
+
class << self
|
8
|
+
attr_writer :minimum_script_timeout
|
9
|
+
|
10
|
+
def minimum_script_timeout
|
11
|
+
@minimum_script_timeout ||= 2
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,31 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Watir::Element do
|
4
|
-
describe "#
|
4
|
+
describe "#dom_changed?" do
|
5
5
|
context "when DOM is changed" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
6
|
+
it "waits using mutation observer" do
|
7
|
+
@browser.button(id: "quick").click
|
8
|
+
expect(@browser.div.wait_until(&:dom_changed?).spans.count).to eq(20)
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
it "waits using custom interval" do
|
12
|
+
@browser.button(id: "long").click
|
13
|
+
expect(@browser.div.wait_until(&:dom_changed?).spans.count).to eq(5)
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
it "raises timeout error" do
|
17
|
+
@browser.button(id: "quick").click
|
18
|
+
expect { @browser.div.wait_until(timeout: 1, &:dom_changed?) }.to raise_error(Watir::Wait::TimeoutError)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "resets script_timeout" do
|
22
|
+
@browser.driver.manage.timeouts.script_timeout = 7
|
23
|
+
@browser.button(id: "quick").click
|
24
|
+
@browser.div.wait_until(&:dom_changed?)
|
25
|
+
expect(@browser.driver.manage.timeouts.script_timeout).to eq(7)
|
26
|
+
end
|
21
27
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
28
|
+
context "when run more than one time" do
|
29
|
+
it "waits for DOM consecutively" do
|
30
|
+
3.times do |i|
|
31
|
+
sleep 1
|
32
|
+
@browser.button(id: "quick").click
|
33
|
+
expect(@browser.div.wait_until(&:dom_changed?).spans.count).to eq(20 * (i + 1))
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/watir-dom-wait.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
|
5
4
|
Gem::Specification.new do |spec|
|
6
5
|
spec.name = "watir-dom-wait"
|
7
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.4.0"
|
8
7
|
spec.authors = ["Alex Rodionov"]
|
9
8
|
spec.email = %w(p0deje@gmail.com)
|
10
9
|
spec.description = "Watir extension which provides with method to check for DOM changes."
|
@@ -17,10 +16,8 @@ Gem::Specification.new do |spec|
|
|
17
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
17
|
spec.require_paths = ["lib"]
|
19
18
|
|
20
|
-
spec.add_dependency "watir", ">=
|
19
|
+
spec.add_dependency "watir", ">= 7.0"
|
21
20
|
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
23
21
|
spec.add_development_dependency "rake"
|
24
22
|
spec.add_development_dependency "rspec"
|
25
|
-
spec.add_development_dependency "pry"
|
26
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-dom-wait
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.3'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.3'
|
26
|
+
version: '7.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +52,6 @@ dependencies:
|
|
66
52
|
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
55
|
description: Watir extension which provides with method to check for DOM changes.
|
84
56
|
email:
|
85
57
|
- p0deje@gmail.com
|
@@ -105,7 +77,7 @@ homepage: https://github.com/p0deje/watir-dom-wait
|
|
105
77
|
licenses:
|
106
78
|
- MIT
|
107
79
|
metadata: {}
|
108
|
-
post_install_message:
|
80
|
+
post_install_message:
|
109
81
|
rdoc_options: []
|
110
82
|
require_paths:
|
111
83
|
- lib
|
@@ -120,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
92
|
- !ruby/object:Gem::Version
|
121
93
|
version: '0'
|
122
94
|
requirements: []
|
123
|
-
|
124
|
-
|
125
|
-
signing_key:
|
95
|
+
rubygems_version: 3.3.3
|
96
|
+
signing_key:
|
126
97
|
specification_version: 4
|
127
98
|
summary: Watir extension which provides with method to check for DOM changes.
|
128
99
|
test_files:
|