watir-dom-wait 0.3.3 → 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: 7f58c8ee42532287c905e965095b1b51b10d8a5a
4
- data.tar.gz: 68916d0b9e8a00999a460428727297b91378697a
2
+ SHA256:
3
+ metadata.gz: 0b066817603bde9fef59bcc7274963517dc2291e06fdae4d5543c333a6588e24
4
+ data.tar.gz: 98adfb587832f044bf09b83d0910699ae15c7601242f5984af0faa3f4191bade
5
5
  SHA512:
6
- metadata.gz: cdebe4f8e76f264593f2ed3ce7af40153a9b4e20778936586bd54a62b2403d6709a77a4494420a7b825cd807352149b8eca4a41ed43bacd3b50d80d1ad206ab4
7
- data.tar.gz: 794bba96d303eb4aae5380bf25dcaf1e561a5330209455ef1518a2e0eb8671792fced2034929fa95c6a472dc54c659cb1cd83240e9bf8c0d7a08864d3524f6b0
6
+ metadata.gz: ac4f364fa642af309078537e8ad370733668b03f34dbdb98d996d9e8314c5a58407aa75abce0e5bb24abf4ed90292e8f57f472290af52ca0796cdf865e95a3b2
7
+ data.tar.gz: 882b8fff9e41ad4bc147a52f589935801f914ab3d02d217df9fb7c5b1cf9235e5efa4c1c56779fd5dd06b01d79f8924db3ff109c7e9474d4a469334697d43e23
@@ -19,7 +19,8 @@ module Watir
19
19
  def dom_changed?(delay: 1.1)
20
20
  element_call do
21
21
  begin
22
- driver.manage.timeouts.script_timeout = delay + 1
22
+ script_timeout = driver.manage.timeouts.script_timeout
23
+ driver.manage.timeouts.script_timeout = delay + Watir::DOM::Wait.minimum_script_timeout
23
24
  driver.execute_async_script(DOM_WAIT_JS, wd, delay)
24
25
  rescue Selenium::WebDriver::Error::JavascriptError => error
25
26
  # sometimes we start script execution before new page is loaded and
@@ -27,9 +28,7 @@ module Watir
27
28
  retry if error.message.include?('document unloaded while waiting for result')
28
29
  raise
29
30
  ensure
30
- # TODO: make sure we rollback to user-defined timeout
31
- # blocked by https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6608
32
- driver.manage.timeouts.script_timeout = 1
31
+ driver.manage.timeouts.script_timeout = script_timeout
33
32
  end
34
33
  end
35
34
  end
@@ -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
@@ -4,7 +4,11 @@ RSpec.configure do |spec|
4
4
  spec.filter_run_excluding bug: /\d+/
5
5
 
6
6
  spec.before(:all) do
7
- Selenium::WebDriver::Chrome.path = "#{File.dirname(__FILE__)}/../bin/google-chrome" if ENV['TRAVIS']
7
+ opts = {}
8
+ if ENV['TRAVIS']
9
+ Selenium::WebDriver::Chrome.path = "#{File.dirname(__FILE__)}/../bin/google-chrome"
10
+ opts[:args] = ['no-sandbox']
11
+ end
8
12
  @browser = Watir::Browser.new(:chrome, opts)
9
13
  @browser.goto "data:text/html,#{File.read('spec/support/html/wait_for_dom.html')}"
10
14
  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
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "watir-dom-wait"
6
- spec.version = "0.3.3"
6
+ spec.version = "0.4.0"
7
7
  spec.authors = ["Alex Rodionov"]
8
8
  spec.email = %w(p0deje@gmail.com)
9
9
  spec.description = "Watir extension which provides with method to check for DOM changes."
@@ -16,9 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency "watir", ">= 6.4"
19
+ spec.add_dependency "watir", ">= 7.0"
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
21
  spec.add_development_dependency "rake"
23
22
  spec.add_development_dependency "rspec"
24
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.3
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-07-28 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.4'
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.4'
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
@@ -91,7 +77,7 @@ homepage: https://github.com/p0deje/watir-dom-wait
91
77
  licenses:
92
78
  - MIT
93
79
  metadata: {}
94
- post_install_message:
80
+ post_install_message:
95
81
  rdoc_options: []
96
82
  require_paths:
97
83
  - lib
@@ -106,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
92
  - !ruby/object:Gem::Version
107
93
  version: '0'
108
94
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.6.11
111
- signing_key:
95
+ rubygems_version: 3.3.3
96
+ signing_key:
112
97
  specification_version: 4
113
98
  summary: Watir extension which provides with method to check for DOM changes.
114
99
  test_files: