watir 6.3.0 → 6.4.0.rc1
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 +4 -4
- data/CHANGES.md +4 -0
- data/lib/watir/browser.rb +12 -15
- data/lib/watir/element_collection.rb +1 -1
- data/lib/watir/elements/element.rb +69 -51
- data/lib/watir/elements/iframe.rb +11 -5
- data/lib/watir/locators/element/locator.rb +2 -4
- data/lib/watir/locators/element/validator.rb +0 -5
- data/lib/watir/wait/timer.rb +5 -1
- data/spec/watirspec/alert_spec.rb +8 -3
- data/spec/watirspec/elements/button_spec.rb +4 -0
- data/spec/watirspec/elements/text_field_spec.rb +4 -0
- data/spec/watirspec/relaxed_locate_spec.rb +1 -121
- data/spec/watirspec/wait_spec.rb +1 -1
- data/watir.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b67d137fb553725a3560f0a319874cc5306ccb4
|
|
4
|
+
data.tar.gz: 94a5b69d2a27b360ba506e974553fec6f5b7dcf8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57eff53b2276128e6b44b27c840159aabe135e24b0fb76d255ab67d656de25e525ff90f1a9ff99ae8059410870fd424ddb53db3dab41495f177246d8f1410590
|
|
7
|
+
data.tar.gz: '08692e0b7d43a2b9aa9092ce1a2009f72d1bce025bf5f8918a6d7167353c08c9a23808230179694267d62c94962c5bfb97d0d45bebf8e1f2cd75a04d21f4b489'
|
data/CHANGES.md
CHANGED
data/lib/watir/browser.rb
CHANGED
|
@@ -9,6 +9,7 @@ module Watir
|
|
|
9
9
|
include HasWindow
|
|
10
10
|
include Waitable
|
|
11
11
|
|
|
12
|
+
attr_writer :default_context
|
|
12
13
|
attr_reader :driver
|
|
13
14
|
attr_reader :after_hooks
|
|
14
15
|
alias_method :wd, :driver # ensures duck typing with Watir::Element
|
|
@@ -51,8 +52,8 @@ module Watir
|
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
@after_hooks = AfterHooks.new(self)
|
|
54
|
-
@current_frame = nil
|
|
55
55
|
@closed = false
|
|
56
|
+
@default_context = true
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def inspect
|
|
@@ -292,10 +293,7 @@ module Watir
|
|
|
292
293
|
#
|
|
293
294
|
|
|
294
295
|
def exist?
|
|
295
|
-
|
|
296
|
-
true
|
|
297
|
-
rescue Exception::NoMatchingWindowFoundException, Exception::Error
|
|
298
|
-
false
|
|
296
|
+
!@closed && window.present?
|
|
299
297
|
end
|
|
300
298
|
alias_method :exists?, :exist?
|
|
301
299
|
|
|
@@ -306,17 +304,16 @@ module Watir
|
|
|
306
304
|
#
|
|
307
305
|
|
|
308
306
|
def assert_exists
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
307
|
+
ensure_context
|
|
308
|
+
return if window.present?
|
|
309
|
+
raise Exception::NoMatchingWindowFoundException, "browser window was closed"
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def ensure_context
|
|
313
|
+
raise Exception::Error, "browser was closed" if @closed
|
|
314
|
+
driver.switch_to.default_content unless @default_context
|
|
315
|
+
@default_context = true
|
|
317
316
|
end
|
|
318
|
-
alias_method :wait_for_exists, :assert_exists
|
|
319
|
-
alias_method :wait_for_present, :assert_exists
|
|
320
317
|
|
|
321
318
|
def browser
|
|
322
319
|
self
|
|
@@ -114,7 +114,7 @@ module Watir
|
|
|
114
114
|
private
|
|
115
115
|
|
|
116
116
|
def elements
|
|
117
|
-
@query_scope.
|
|
117
|
+
@query_scope.send :ensure_context
|
|
118
118
|
|
|
119
119
|
element_validator = element_validator_class.new
|
|
120
120
|
selector_builder = selector_builder_class.new(@query_scope, @selector, element_class.attribute_list)
|
|
@@ -364,7 +364,8 @@ module Watir
|
|
|
364
364
|
#
|
|
365
365
|
|
|
366
366
|
def wd
|
|
367
|
-
|
|
367
|
+
return driver if @element.is_a? FramedDriver
|
|
368
|
+
assert_exists if @element.nil?
|
|
368
369
|
@element
|
|
369
370
|
end
|
|
370
371
|
|
|
@@ -439,17 +440,17 @@ module Watir
|
|
|
439
440
|
|
|
440
441
|
if tag_name == "input"
|
|
441
442
|
klass = case elem.attribute(:type)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
443
|
+
when *Button::VALID_TYPES
|
|
444
|
+
Button
|
|
445
|
+
when 'checkbox'
|
|
446
|
+
CheckBox
|
|
447
|
+
when 'radio'
|
|
448
|
+
Radio
|
|
449
|
+
when 'file'
|
|
450
|
+
FileField
|
|
451
|
+
else
|
|
452
|
+
TextField
|
|
453
|
+
end
|
|
453
454
|
else
|
|
454
455
|
klass = Watir.element_class_for(tag_name)
|
|
455
456
|
end
|
|
@@ -500,42 +501,30 @@ module Watir
|
|
|
500
501
|
return if exists? # Performance shortcut
|
|
501
502
|
|
|
502
503
|
begin
|
|
503
|
-
@query_scope.wait_for_exists
|
|
504
|
+
@query_scope.wait_for_exists unless @query_scope.is_a? Browser
|
|
504
505
|
wait_until(&:exists?)
|
|
505
506
|
rescue Watir::Wait::TimeoutError
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
message << "waiting for an Element to exist. If the test is still passing, "
|
|
509
|
-
message << "consider using Element#exists? instead of rescuing UnknownObjectException"
|
|
510
|
-
warn message
|
|
511
|
-
end
|
|
512
|
-
raise unknown_exception, "timed out after #{Watir.default_timeout} seconds, "\
|
|
513
|
-
"waiting for #{inspect} to be located"
|
|
507
|
+
msg = "timed out after #{Watir.default_timeout} seconds, waiting for #{inspect} to be located"
|
|
508
|
+
raise unknown_exception, msg
|
|
514
509
|
end
|
|
515
510
|
end
|
|
516
511
|
|
|
517
512
|
def wait_for_present
|
|
518
|
-
return
|
|
513
|
+
return visible? unless Watir.relaxed_locate?
|
|
514
|
+
return if present?
|
|
519
515
|
|
|
520
|
-
wait_for_exists
|
|
521
516
|
begin
|
|
522
517
|
@query_scope.wait_for_present
|
|
523
518
|
wait_until_present
|
|
524
|
-
rescue Watir::Wait::TimeoutError
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
message << "waiting for an Element to be present. If the test is still passing, "
|
|
528
|
-
message << "consider using Element#exists? instead of rescuing UnknownObjectException"
|
|
529
|
-
warn message
|
|
530
|
-
end
|
|
531
|
-
raise unknown_exception, "element located, but #{ex.message}"
|
|
519
|
+
rescue Watir::Wait::TimeoutError
|
|
520
|
+
msg = "element located, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspect} to be present"
|
|
521
|
+
raise unknown_exception, msg
|
|
532
522
|
end
|
|
533
523
|
end
|
|
534
524
|
|
|
535
525
|
def wait_for_enabled
|
|
536
526
|
return assert_enabled unless Watir.relaxed_locate?
|
|
537
527
|
|
|
538
|
-
wait_for_present
|
|
539
528
|
begin
|
|
540
529
|
wait_until(&:enabled?)
|
|
541
530
|
rescue Watir::Wait::TimeoutError
|
|
@@ -545,9 +534,12 @@ module Watir
|
|
|
545
534
|
end
|
|
546
535
|
|
|
547
536
|
def wait_for_writable
|
|
548
|
-
|
|
549
|
-
|
|
537
|
+
wait_for_exists
|
|
550
538
|
wait_for_enabled
|
|
539
|
+
unless Watir.relaxed_locate?
|
|
540
|
+
raise_writable unless !respond_to?(:readonly?) || !readonly?
|
|
541
|
+
end
|
|
542
|
+
|
|
551
543
|
begin
|
|
552
544
|
wait_until { !respond_to?(:readonly?) || !readonly? }
|
|
553
545
|
rescue Watir::Wait::TimeoutError
|
|
@@ -559,7 +551,7 @@ module Watir
|
|
|
559
551
|
# Ensure that the element exists, making sure that it is not stale and located if necessary
|
|
560
552
|
def assert_exists
|
|
561
553
|
if @element && @selector.empty?
|
|
562
|
-
ensure_context
|
|
554
|
+
@query_scope.ensure_context
|
|
563
555
|
reset! if stale?
|
|
564
556
|
elsif @element && !stale?
|
|
565
557
|
return
|
|
@@ -577,13 +569,13 @@ module Watir
|
|
|
577
569
|
end
|
|
578
570
|
|
|
579
571
|
def locate
|
|
580
|
-
ensure_context
|
|
572
|
+
@query_scope.ensure_context
|
|
581
573
|
|
|
582
574
|
element_validator = element_validator_class.new
|
|
583
575
|
selector_builder = selector_builder_class.new(@query_scope, @selector, self.class.attribute_list)
|
|
584
576
|
locator = locator_class.new(@query_scope, @selector, selector_builder, element_validator)
|
|
585
577
|
|
|
586
|
-
locator.locate
|
|
578
|
+
@element = locator.locate
|
|
587
579
|
end
|
|
588
580
|
|
|
589
581
|
def selector_string
|
|
@@ -591,12 +583,31 @@ module Watir
|
|
|
591
583
|
"#{@query_scope.selector_string} --> #{@selector.inspect}"
|
|
592
584
|
end
|
|
593
585
|
|
|
586
|
+
# Ensure the driver is in the desired browser context
|
|
587
|
+
def ensure_context
|
|
588
|
+
assert_exists
|
|
589
|
+
end
|
|
590
|
+
|
|
594
591
|
private
|
|
595
592
|
|
|
596
593
|
def unknown_exception
|
|
597
594
|
Watir::Exception::UnknownObjectException
|
|
598
595
|
end
|
|
599
596
|
|
|
597
|
+
def raise_writable
|
|
598
|
+
message = "element present and enabled, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspect} to not be readonly"
|
|
599
|
+
raise ObjectReadOnlyException, message
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
def raise_disabled
|
|
603
|
+
message = "element present and enabled, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspect} to not be disabled"
|
|
604
|
+
raise ObjectDisabledException, message
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
def raise_present
|
|
608
|
+
raise unknown_exception, "element located, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspect} to be present"
|
|
609
|
+
end
|
|
610
|
+
|
|
600
611
|
def locator_class
|
|
601
612
|
Kernel.const_get("#{Watir.locator_namespace}::#{element_class_name}::Locator")
|
|
602
613
|
rescue NameError
|
|
@@ -619,11 +630,6 @@ module Watir
|
|
|
619
630
|
self.class.name.split('::').last
|
|
620
631
|
end
|
|
621
632
|
|
|
622
|
-
# Ensure the driver is in the desired browser context
|
|
623
|
-
def ensure_context
|
|
624
|
-
@query_scope.is_a?(IFrame) ? @query_scope.switch_to! : @query_scope.assert_exists
|
|
625
|
-
end
|
|
626
|
-
|
|
627
633
|
def attribute?(attribute_name)
|
|
628
634
|
!attribute_value(attribute_name).nil?
|
|
629
635
|
end
|
|
@@ -634,14 +640,6 @@ module Watir
|
|
|
634
640
|
end
|
|
635
641
|
end
|
|
636
642
|
|
|
637
|
-
def assert_writable
|
|
638
|
-
assert_enabled
|
|
639
|
-
|
|
640
|
-
if respond_to?(:readonly?) && readonly?
|
|
641
|
-
raise ObjectReadOnlyException, "object is read only #{inspect}"
|
|
642
|
-
end
|
|
643
|
-
end
|
|
644
|
-
|
|
645
643
|
def assert_is_element(obj)
|
|
646
644
|
unless obj.kind_of? Watir::Element
|
|
647
645
|
raise TypeError, "execpted Watir::Element, got #{obj.inspect}:#{obj.class}"
|
|
@@ -652,10 +650,30 @@ module Watir
|
|
|
652
650
|
already_locked = Wait.timer.locked?
|
|
653
651
|
Wait.timer = Wait::Timer.new(timeout: Watir.default_timeout) unless already_locked
|
|
654
652
|
begin
|
|
655
|
-
|
|
653
|
+
if exist_check == :wait_for_enabled
|
|
654
|
+
if self.is_a?(Input) || self.is_a?(Button) || self.is_a?(Select) || self.is_a?(Option)
|
|
655
|
+
wait_for_enabled
|
|
656
|
+
else
|
|
657
|
+
wait_for_exists
|
|
658
|
+
end
|
|
659
|
+
else
|
|
660
|
+
send(exist_check)
|
|
661
|
+
end
|
|
662
|
+
|
|
656
663
|
yield
|
|
657
664
|
rescue Selenium::WebDriver::Error::StaleElementReferenceError
|
|
658
665
|
retry
|
|
666
|
+
rescue Selenium::WebDriver::Error::ElementNotVisibleError, Selenium::WebDriver::Error::ElementNotInteractableError
|
|
667
|
+
raise_present unless Wait.timer.remaining_time > 0
|
|
668
|
+
raise_present unless exist_check == :wait_for_present || exist_check == :wait_for_enabled
|
|
669
|
+
retry
|
|
670
|
+
rescue Selenium::WebDriver::Error::InvalidElementStateError => ex
|
|
671
|
+
raise_disabled unless Wait.timer.remaining_time > 0
|
|
672
|
+
raise_disabled unless exist_check == :wait_for_writable || exist_check == :wait_for_enabled
|
|
673
|
+
raise_disabled unless ex.message.include?('user-editable')
|
|
674
|
+
retry
|
|
675
|
+
rescue Selenium::WebDriver::Error::NoSuchWindowError
|
|
676
|
+
raise Exception::NoMatchingWindowFoundException, "browser window was closed"
|
|
659
677
|
ensure
|
|
660
678
|
Wait.timer.reset! unless already_locked
|
|
661
679
|
end
|
|
@@ -3,7 +3,7 @@ module Watir
|
|
|
3
3
|
|
|
4
4
|
def locate
|
|
5
5
|
return if @selector.empty?
|
|
6
|
-
@query_scope.
|
|
6
|
+
@query_scope.ensure_context
|
|
7
7
|
|
|
8
8
|
selector = @selector.merge(tag_name: frame_tag)
|
|
9
9
|
element_validator = element_validator_class.new
|
|
@@ -13,7 +13,7 @@ module Watir
|
|
|
13
13
|
element = locator.locate
|
|
14
14
|
element or raise unknown_exception, "unable to locate #{@selector[:tag_name]} using #{selector_string}"
|
|
15
15
|
|
|
16
|
-
FramedDriver.new(element,
|
|
16
|
+
@element = FramedDriver.new(element, browser)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def ==(other)
|
|
@@ -51,7 +51,7 @@ module Watir
|
|
|
51
51
|
|
|
52
52
|
def html
|
|
53
53
|
wait_for_exists
|
|
54
|
-
|
|
54
|
+
@element.page_source
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
#
|
|
@@ -67,6 +67,10 @@ module Watir
|
|
|
67
67
|
browser.send :wrap_elements_in, self, returned
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
def ensure_context
|
|
71
|
+
switch_to!
|
|
72
|
+
end
|
|
73
|
+
|
|
70
74
|
private
|
|
71
75
|
|
|
72
76
|
def frame_tag
|
|
@@ -118,9 +122,10 @@ module Watir
|
|
|
118
122
|
#
|
|
119
123
|
|
|
120
124
|
class FramedDriver
|
|
121
|
-
def initialize(element,
|
|
125
|
+
def initialize(element, browser)
|
|
122
126
|
@element = element
|
|
123
|
-
@
|
|
127
|
+
@browser = browser
|
|
128
|
+
@driver = browser.driver
|
|
124
129
|
end
|
|
125
130
|
|
|
126
131
|
def ==(other)
|
|
@@ -152,6 +157,7 @@ module Watir
|
|
|
152
157
|
|
|
153
158
|
def switch!
|
|
154
159
|
@driver.switch_to.frame @element
|
|
160
|
+
@browser.default_context = false
|
|
155
161
|
rescue Selenium::WebDriver::Error::NoSuchFrameError => e
|
|
156
162
|
raise Exception::UnknownFrameException, e.message
|
|
157
163
|
end
|
|
@@ -44,10 +44,8 @@ module Watir
|
|
|
44
44
|
find_first_by_multiple
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
# It is also used to alter behavior of methods locating more than one type of element
|
|
50
|
-
# (e.g. text_field locates both input and textarea)
|
|
47
|
+
# Validation not necessary if Watir builds the xpath
|
|
48
|
+
return element unless @selector.key?(:xpath) || @selector.key?(:css)
|
|
51
49
|
element_validator.validate(element, @selector) if element
|
|
52
50
|
rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::StaleElementReferenceError
|
|
53
51
|
nil
|
|
@@ -10,11 +10,6 @@ module Watir
|
|
|
10
10
|
return unless selector_tag_name === element_tag_name
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
if element_tag_name == 'input'
|
|
14
|
-
# TODO - Verify this is desired behavior based on https://bugzilla.mozilla.org/show_bug.cgi?id=1290963
|
|
15
|
-
return if selector[:type] && selector[:type] != element.attribute(:type).downcase
|
|
16
|
-
end
|
|
17
|
-
|
|
18
13
|
element
|
|
19
14
|
end
|
|
20
15
|
end
|
data/lib/watir/wait/timer.rb
CHANGED
|
@@ -2,8 +2,11 @@ module Watir
|
|
|
2
2
|
module Wait
|
|
3
3
|
class Timer
|
|
4
4
|
|
|
5
|
+
attr_reader :remaining_time
|
|
6
|
+
|
|
5
7
|
def initialize(timeout: nil)
|
|
6
8
|
@end_time = current_time + timeout if timeout
|
|
9
|
+
@remaining_time = @end_time - current_time if @end_time
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
#
|
|
@@ -17,7 +20,8 @@ module Watir
|
|
|
17
20
|
end_time = @end_time || current_time + timeout
|
|
18
21
|
loop do
|
|
19
22
|
yield(block)
|
|
20
|
-
|
|
23
|
+
@remaining_time = end_time - current_time
|
|
24
|
+
break if @remaining_time < 0
|
|
21
25
|
end
|
|
22
26
|
end
|
|
23
27
|
|
|
@@ -57,9 +57,14 @@ describe 'Alert API' do
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it 'raises error if alert is not present after timeout' do
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
begin
|
|
61
|
+
Watir.default_timeout = 2
|
|
62
|
+
expect {
|
|
63
|
+
browser.alert.wait_until_present.ok
|
|
64
|
+
}.to raise_error(Watir::Wait::TimeoutError)
|
|
65
|
+
ensure
|
|
66
|
+
Watir.default_timeout = 30
|
|
67
|
+
end
|
|
63
68
|
end
|
|
64
69
|
end
|
|
65
70
|
end
|
|
@@ -226,6 +226,10 @@ describe "Button" do
|
|
|
226
226
|
it "raises UnknownObjectException if the button doesn't exist" do
|
|
227
227
|
expect { browser.button(name: "no_such_name").enabled? }.to raise_unknown_object_exception
|
|
228
228
|
end
|
|
229
|
+
|
|
230
|
+
it "raises ObjectDisabledException if disabled button is clicked" do
|
|
231
|
+
expect { browser.button(name: "new_user_submit_disabled").click }.to raise_object_disabled_exception
|
|
232
|
+
end
|
|
229
233
|
end
|
|
230
234
|
|
|
231
235
|
describe "#disabled?" do
|
|
@@ -197,6 +197,10 @@ describe "TextField" do
|
|
|
197
197
|
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
198
198
|
expect { browser.text_field(id: 'no_such_id').readonly? }.to raise_unknown_object_exception
|
|
199
199
|
end
|
|
200
|
+
|
|
201
|
+
it "raises UnknownReadOnlyException if sending keys to readonly element" do
|
|
202
|
+
expect { browser.text_field(id: 'new_user_code').set 'foo' }.to raise_object_read_only_exception
|
|
203
|
+
end
|
|
200
204
|
end
|
|
201
205
|
|
|
202
206
|
# Manipulation methods
|
|
@@ -50,108 +50,6 @@ describe 'Watir#relaxed_locate?' do
|
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
context 'when evaluating order of failure precedence' do
|
|
54
|
-
it 'fails first for parent not existing' do
|
|
55
|
-
begin
|
|
56
|
-
Watir.default_timeout = 0
|
|
57
|
-
inspected = '#<Watir::Div: located: false; {:id=>"no_parent", :tag_name=>"div"}>'
|
|
58
|
-
element = browser.div(id: 'no_parent').div(id: 'no_child')
|
|
59
|
-
error = Watir::Exception::UnknownObjectException
|
|
60
|
-
message = "timed out after #{Watir.default_timeout} seconds, waiting for #{inspected} to be located"
|
|
61
|
-
expect { element.click }.to raise_exception(error, message)
|
|
62
|
-
ensure
|
|
63
|
-
Watir.default_timeout = 30
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'fails for child not existing if parent exists' do
|
|
68
|
-
begin
|
|
69
|
-
Watir.default_timeout = 0
|
|
70
|
-
inspected = '#<Watir::Div: located: false; {:id=>"buttons", :tag_name=>"div"} --> {:id=>"no_child", :tag_name=>"div"}>'
|
|
71
|
-
element = browser.div(id: 'buttons').div(id: 'no_child')
|
|
72
|
-
error = Watir::Exception::UnknownObjectException
|
|
73
|
-
message = "timed out after #{Watir.default_timeout} seconds, waiting for #{inspected} to be located"
|
|
74
|
-
expect { element.click }.to raise_exception(error, message)
|
|
75
|
-
ensure
|
|
76
|
-
Watir.default_timeout = 30
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it 'fails for parent not present if child exists' do
|
|
81
|
-
begin
|
|
82
|
-
Watir.default_timeout = 0.5
|
|
83
|
-
inspected = '#<Watir::Div: located: true; {:id=>"also_hidden", :tag_name=>"div"}>'
|
|
84
|
-
element = browser.div(id: 'also_hidden').div(id: 'hidden_child')
|
|
85
|
-
error = Watir::Exception::UnknownObjectException
|
|
86
|
-
message = "element located, but timed out after #{Watir.default_timeout} seconds, waiting for true condition on #{inspected}"
|
|
87
|
-
allow($stderr).to receive(:write).twice
|
|
88
|
-
expect { element.click }.to raise_exception(error, message)
|
|
89
|
-
ensure
|
|
90
|
-
Watir.default_timeout = 30
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it 'fails for child not present if parent is present' do
|
|
95
|
-
begin
|
|
96
|
-
Watir.default_timeout = 0.5
|
|
97
|
-
inspected = '#<Watir::Button: located: true; {:id=>"buttons", :tag_name=>"div"} --> {:id=>"btn2", :tag_name=>"button"}>'
|
|
98
|
-
element = browser.div(id: 'buttons').button(id: 'btn2')
|
|
99
|
-
error = Watir::Exception::UnknownObjectException
|
|
100
|
-
message = "element located, but timed out after #{Watir.default_timeout} seconds, waiting for true condition on #{inspected}"
|
|
101
|
-
allow($stderr).to receive(:write).twice
|
|
102
|
-
expect { element.click }.to raise_exception(error, message)
|
|
103
|
-
ensure
|
|
104
|
-
Watir.default_timeout = 30
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it 'fails for element not enabled if present' do
|
|
109
|
-
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
|
110
|
-
begin
|
|
111
|
-
Watir.default_timeout = 0.5
|
|
112
|
-
inspected = '#<Watir::TextField: located: true; {:id=>"new_user", :tag_name=>"form"} --> {:id=>"good_luck", :tag_name=>"input or textarea", :type=>"(any text type)"}>'
|
|
113
|
-
element = browser.form(id: 'new_user').text_field(id: 'good_luck')
|
|
114
|
-
error = Watir::Exception::ObjectDisabledException
|
|
115
|
-
message = "element present, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspected} to be enabled"
|
|
116
|
-
expect { element.set('foo') }.to raise_exception(error, message)
|
|
117
|
-
ensure
|
|
118
|
-
Watir.default_timeout = 30
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it 'fails for element being readonly if enabled' do
|
|
123
|
-
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
|
124
|
-
begin
|
|
125
|
-
Watir.default_timeout = 0.5
|
|
126
|
-
inspected = '#<Watir::TextField: located: true; {:id=>"new_user", :tag_name=>"form"} --> {:id=>"new_user_code", :tag_name=>"input or textarea", :type=>"(any text type)"}>'
|
|
127
|
-
element = browser.form(id: 'new_user').text_field(id: 'new_user_code')
|
|
128
|
-
error = Watir::Exception::ObjectReadOnlyException
|
|
129
|
-
message = "element present and enabled, but timed out after #{Watir.default_timeout} seconds, waiting for #{inspected} to not be readonly"
|
|
130
|
-
expect { element.set('foo') }.to raise_exception(error, message)
|
|
131
|
-
ensure
|
|
132
|
-
Watir.default_timeout = 30
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it 'gives warning when rescuing for flow control' do
|
|
138
|
-
begin
|
|
139
|
-
Watir.default_timeout = 1
|
|
140
|
-
element = browser.link(id: 'not_there')
|
|
141
|
-
message = "This code has slept for the duration of the default timeout "
|
|
142
|
-
message << "waiting for an Element to exist. If the test is still passing, "
|
|
143
|
-
message << "consider using Element#exists? instead of rescuing UnknownObjectException\n"
|
|
144
|
-
expect do
|
|
145
|
-
begin
|
|
146
|
-
element.click
|
|
147
|
-
rescue Watir::Exception::UnknownObjectException
|
|
148
|
-
end
|
|
149
|
-
end.to output(message).to_stderr
|
|
150
|
-
ensure
|
|
151
|
-
Watir.default_timeout = 30
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
53
|
it 'ensures all checks happen once even if time has expired' do
|
|
156
54
|
begin
|
|
157
55
|
Watir.default_timeout = -1
|
|
@@ -160,19 +58,6 @@ describe 'Watir#relaxed_locate?' do
|
|
|
160
58
|
Watir.default_timeout = 30
|
|
161
59
|
end
|
|
162
60
|
end
|
|
163
|
-
|
|
164
|
-
it 'ensures that the same timeout is used for all of the calls' do
|
|
165
|
-
begin
|
|
166
|
-
Watir.default_timeout = 1.1
|
|
167
|
-
browser.a(id: 'add_foobar').click
|
|
168
|
-
allow($stderr).to receive(:write).twice
|
|
169
|
-
# Element created after 1 second, and displays after 2 seconds
|
|
170
|
-
# Click will only raise this exception if the timer is not reset between #wait_for_exists and #wait_for_present
|
|
171
|
-
expect { browser.div(id: 'foobar').click }.to raise_exception Watir::Exception::UnknownObjectException
|
|
172
|
-
ensure
|
|
173
|
-
Watir.default_timeout = 30
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
61
|
end
|
|
177
62
|
end
|
|
178
63
|
|
|
@@ -202,12 +87,7 @@ describe 'Watir#relaxed_locate?' do
|
|
|
202
87
|
start_time = ::Time.now
|
|
203
88
|
browser.a(id: 'show_bar').click
|
|
204
89
|
|
|
205
|
-
|
|
206
|
-
expect { browser.div(id: 'bar').click }.to raise_exception(Selenium::WebDriver::Error::ElementNotInteractableError)
|
|
207
|
-
end
|
|
208
|
-
not_compliant_on :firefox do
|
|
209
|
-
expect { browser.div(id: 'bar').click }.to raise_exception(Selenium::WebDriver::Error::ElementNotVisibleError)
|
|
210
|
-
end
|
|
90
|
+
expect { browser.div(id: 'bar').click }.to raise_unknown_object_exception
|
|
211
91
|
|
|
212
92
|
expect(::Time.now - start_time).to be < 1
|
|
213
93
|
end
|
data/spec/watirspec/wait_spec.rb
CHANGED
|
@@ -239,7 +239,7 @@ not_compliant_on :safari do
|
|
|
239
239
|
describe "#wait_while_present" do
|
|
240
240
|
it "waits until the element disappears" do
|
|
241
241
|
browser.a(id: 'hide_foo').click
|
|
242
|
-
expect { browser.div(id: 'foo').wait_while_present(timeout:
|
|
242
|
+
expect { browser.div(id: 'foo').wait_while_present(timeout: 2) }.to_not raise_exception
|
|
243
243
|
end
|
|
244
244
|
|
|
245
245
|
it "times out if the element doesn't disappear" do
|
data/watir.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: watir
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.4.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Rodionov
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-06-
|
|
12
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: selenium-webdriver
|
|
@@ -476,9 +476,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
476
476
|
version: '0'
|
|
477
477
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
478
478
|
requirements:
|
|
479
|
-
- - "
|
|
479
|
+
- - ">"
|
|
480
480
|
- !ruby/object:Gem::Version
|
|
481
|
-
version:
|
|
481
|
+
version: 1.3.1
|
|
482
482
|
requirements: []
|
|
483
483
|
rubyforge_project: watir
|
|
484
484
|
rubygems_version: 2.5.2
|