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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0fc11a16d952457dedccdb310aa696335c614471
4
- data.tar.gz: 2c0ecf8e599cccbb4e4f64b3576052626dd780da
2
+ SHA256:
3
+ metadata.gz: 0b066817603bde9fef59bcc7274963517dc2291e06fdae4d5543c333a6588e24
4
+ data.tar.gz: 98adfb587832f044bf09b83d0910699ae15c7601242f5984af0faa3f4191bade
5
5
  SHA512:
6
- metadata.gz: 690be61ea0f9ca9696855d41a2f2ebd7495f7d40c32a9f974a23b6357efd7ffd3673c4ada09c5ae7c28c47831d1d33097bd56233258ddc5764be98ca9914e7db
7
- data.tar.gz: 3ebe00866f24c2113796268d1de2534029cd03f64394b9b6f50e90cbf004042fe0512b6c4824eecf0c21ac8b739869eeb6907ecee685e7c7917e49dc93f2e091
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
- driver.manage.timeouts.script_timeout = delay + 1
21
- driver.execute_async_script(DOM_WAIT_JS, wd, delay)
22
- rescue Selenium::WebDriver::Error::StaleElementReferenceError
23
- retry
24
- ensure
25
- # TODO: make sure we rollback to user-defined timeout
26
- # blocked by https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6608
27
- driver.manage.timeouts.script_timeout = 1
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
@@ -16,7 +16,7 @@ var exitOnNotStartedModifying = function() {
16
16
  return setTimeout(function() {
17
17
  observer.disconnect();
18
18
  callback(true);
19
- }, 1000);
19
+ }, delay);
20
20
  }
21
21
 
22
22
  // arguments from WebDriver
@@ -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,4 +1,3 @@
1
- require "pry"
2
1
  require "watir-dom-wait"
3
2
 
4
3
  RSpec.configure do |spec|
@@ -19,7 +18,6 @@ RSpec.configure do |spec|
19
18
  end
20
19
 
21
20
  spec.after(:each) do |example|
22
- binding.pry if example.exception && ENV['DEBUG']
23
21
  @browser.refresh
24
22
  end
25
23
  end
@@ -1,31 +1,36 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Watir::Element do
4
- describe "#when_dom_changed" do
4
+ describe "#dom_changed?" do
5
5
  context "when DOM is changed" do
6
- context "when block is not given" do
7
- it "waits using mutation observer" do
8
- @browser.button(id: "quick").click
9
- expect(@browser.div.wait_until(&:dom_changed?).spans.count).to eq(20)
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
- it "waits using custom interval" do
13
- @browser.button(id: "long").click
14
- expect(@browser.div.wait_until(&:dom_changed?).spans.count).to eq(5)
15
- end
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
- it "raises timeout error" do
18
- @browser.button(id: "quick").click
19
- expect { @browser.div.wait_until(timeout: 1, &:dom_changed?) }.to raise_error(Watir::Wait::TimeoutError)
20
- end
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
- context "when run more than one time" do
23
- it "waits for DOM consecutively" do
24
- 3.times do |i|
25
- sleep 1
26
- @browser.button(id: "quick").click
27
- expect(@browser.div.wait_until(&:dom_changed?).spans.count).to eq(20 * (i + 1))
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
@@ -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.3.1"
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", ">= 6.0"
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.3.1
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: 2017-01-14 00:00:00.000000000 Z
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: '6.0'
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: '6.0'
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
- rubyforge_project:
124
- rubygems_version: 2.5.2
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: