rwebspec-webdriver 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -69,7 +69,7 @@ end
69
69
  spec = Gem::Specification.new do |s|
70
70
  s.platform= Gem::Platform::RUBY
71
71
  s.name = "rwebspec-webdriver"
72
- s.version = "0.3.0"
72
+ s.version = "0.3.1"
73
73
  s.summary = "Executable functional specification for web applications in RSpec syntax and Selenium-WebDriver"
74
74
  # s.description = ""
75
75
 
@@ -19,9 +19,6 @@ module RWebSpec
19
19
  include RWebSpec::WebDriver::TestWisePlugin
20
20
  include RWebSpec::WebDriver::Popup
21
21
 
22
- @@default_polling_interval = 1 # second
23
- @@default_timeout = 30 # seconds
24
-
25
22
  # open a browser, and set base_url via hash, but does not acually
26
23
  #
27
24
  # example:
@@ -602,7 +599,7 @@ module RWebSpec
602
599
  # wait_until {puts 'hello'}
603
600
  # wait_until { div(:id, :receipt_date).exists? }
604
601
  #
605
- def wait_until(timeout = @@default_timeout || 30, polling_interval = @@default_polling_interval || 1, & block)
602
+ def wait_until(timeout = $testwise_polling_timeout || 30, polling_interval = $testwise_polling_interval || 1, & block)
606
603
  end_time = ::Time.now + timeout
607
604
 
608
605
  until ::Time.now > end_time
@@ -633,7 +630,7 @@ module RWebSpec
633
630
  #
634
631
  # Warning: this method has not been fully tested, if you are not using Rails, change your parameter accordingly.
635
632
  #
636
- def ajax_wait_for_element(element_id, seconds, status='show', check_interval = @@default_polling_interval)
633
+ def ajax_wait_for_element(element_id, seconds, status='show', check_interval = $testwise_polling_interval)
637
634
  count = 0
638
635
  check_interval = 1 if check_interval < 1 or check_interval > seconds
639
636
  while count < (seconds / check_interval) do
@@ -653,7 +650,7 @@ module RWebSpec
653
650
  #Wait the element with given id to be present in web page
654
651
  #
655
652
  # Warning: this not working in Firefox, try use wait_util or try instead
656
- def wait_for_element(element_id, timeout = @@default_timeout, interval = @@default_polling_interval)
653
+ def wait_for_element(element_id, timeout = $testwise_polling_timeout, interval = $testwise_polling_interval)
657
654
  start_time = Time.now
658
655
  #TODO might not work with Firefox
659
656
  until @web_browser.element_by_id(element_id) do
@@ -46,7 +46,7 @@ module RWebSpec
46
46
  # try { click_link('waiting')}
47
47
  # try(10, 2) { click_button('Search' } # try to click the 'Search' button upto 10 seconds, try every 2 seconds
48
48
  # try { click_button('Search' }
49
- def try(timeout = @@default_timeout, polling_interval = @@default_polling_interval || 1, &block)
49
+ def try(timeout = $testwise_polling_timeout, polling_interval = $testwise_polling_interval || 1, &block)
50
50
  start_time = Time.now
51
51
 
52
52
  last_error = nil
@@ -9,9 +9,6 @@ module RWebSpec
9
9
  module WebDriver
10
10
  module Utils
11
11
 
12
- @@default_polling_interval = 1 # second
13
- @@default_timeout = 30 # seconds
14
-
15
12
  # Using Ruby block syntax to create interesting domain specific language,
16
13
  # may be appeal to someone.
17
14
 
@@ -70,7 +67,7 @@ module RWebSpec
70
67
  # Example
71
68
  # repeat_try(3, 2) { click_button('Search' } # 3 times, 6 seconds in total
72
69
  # repeat_try { click_button('Search' } # using default 5 tries, 2 second interval
73
- def repeat_try(num_tries = @@default_timeout || 30, interval = @@default_polling_interval || 1, & block)
70
+ def repeat_try(num_tries = $testwise_polling_timeout || 30, interval = $testwise_polling_interval || 1, & block)
74
71
  num_tries ||= 1
75
72
  (num_tries - 1).times do |num|
76
73
  begin
@@ -99,7 +96,7 @@ module RWebSpec
99
96
  # try { click_link('waiting')}
100
97
  # try(10, 2) { click_button('Search' } # try to click the 'Search' button upto 10 seconds, try every 2 seconds
101
98
  # try { click_button('Search' }
102
- def try_until(timeout = @@default_timeout, polling_interval = @@default_polling_interval || 1, & block)
99
+ def try_until(timeout = $testwise_polling_timeout, polling_interval = $testwise_polling_interval || 1, & block)
103
100
  start_time = Time.now
104
101
 
105
102
  last_error = nil
@@ -119,7 +116,7 @@ module RWebSpec
119
116
 
120
117
  alias try_upto try_until
121
118
 
122
- def try(timeout = @@default_timeout, polling_interval = @@default_polling_interval || 1, &block)
119
+ def try(timeout = $testwise_polling_timeout, polling_interval = $testwise_polling_interval || 1, &block)
123
120
  puts "Warning: method 'try' is deprecated (won't support in RWebSpec 3), use try_until instead."
124
121
  try_until(timeout, polling_interval) {
125
122
  yield
@@ -17,10 +17,16 @@ require 'spec'
17
17
  require 'selenium-webdriver'
18
18
 
19
19
  unless defined? RWEBSPEC_WEBDRIVER_VERSION
20
- RWEBSPEC_WEBDRIVER_VERSION = "0.3.0"
20
+ RWEBSPEC_WEBDRIVER_VERSION = "0.3.1"
21
21
  end
22
22
 
23
-
23
+
24
+ ## Polling settings
25
+ #
26
+ $testwise_polling_interval = 1 # seconds
27
+
28
+ $testwise_polling_timeout = 30 # seconds
29
+
24
30
  if RUBY_PLATFORM =~ /mswin/ or RUBY_PLATFORM =~ /mingw/
25
31
  $testwise_screenshot_supported = false
26
32
  begin
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Zhimin Zhan