rufus 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +8 -2
- data/lib/rufus.rb +9 -23
- data/lib/rufus/driver.rb +4 -0
- data/lib/rufus/drivers/driver_base.rb +6 -1
- data/lib/rufus/navigation.rb +1 -0
- data/lib/rufus/waiter.rb +25 -0
- data/rufus.gemspec +1 -1
- data/spec/drivers_specs/waiter_spec.rb +23 -0
- data/spec/navigation_spec.rb +3 -0
- data/spec/rufus_spec.rb +73 -54
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTYwYWRhNzY3NTM4NjM1NjQxYzZlYmFiMzk3NTFmMTU4YjIxZjQ0OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjA0N2FhYmYyZmNlZGU4NDNhODczYjlkNGEyOGE3Y2E0MjkzYjYyZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjIzN2IyYmI2NWFlYzc3NTI4NzA4ZjAzYjA4ZTExMGFmMDcwMWJiOTNhYWE1
|
10
|
+
YjI2Y2ExYTlhZTE0ZGMzY2VjMTJjMWU5MTc3NjgzNjEzNDI4NTUzZGIwM2Uw
|
11
|
+
MGRmYTBhMTMwYzM0Njg1OGI2MzJiNzdkYzVhMmFmMWQ3ZTJiZTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDY3MzYxNGEyMDhjZTgwYmU5ZjdjYjk4NTAzMzc3Mzk1MzMyMmQ3MmM4ODkw
|
14
|
+
MDBhMjRlMmE1ZWQwMDEyM2U1Nzg0M2Y3NTExMTRjYzc4YzJmNDk3ZTMyMjcz
|
15
|
+
ODUzOGE4NTAwNzNhMTFhYzE2OWQ0OGIyOTFjYmY1MzA1YjUwMGM=
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Last Updated: 12-
|
1
|
+
Last Updated: 12-12-2013
|
2
2
|
|
3
3
|
This project is intended to facilitate automated testing on iOS devices using cucumber, appium and the Page Object pattern.
|
4
4
|
|
@@ -29,8 +29,14 @@ QUICK START GUIDE
|
|
29
29
|
------------------------------
|
30
30
|
- gem install rufus
|
31
31
|
- require 'rufus' in your Gemfile
|
32
|
-
-
|
32
|
+
- In your env.rb, new up a rufus driver in a method that MUST be named selenium.
|
33
33
|
|
34
|
+
````ruby
|
35
|
+
def selenium
|
36
|
+
@driver ||= new Rufus::Driver.new
|
37
|
+
end
|
38
|
+
````
|
39
|
+
- Create a config.yml in project directory (the one with .xcodeproj in it) with the following information:
|
34
40
|
|
35
41
|
````YAML
|
36
42
|
browser: iOS
|
data/lib/rufus.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rufus/navigation'
|
|
2
2
|
require 'rufus/accessors/accessors'
|
3
3
|
require 'rufus/accessors/view'
|
4
4
|
require 'rufus/accessors/table'
|
5
|
+
require 'rufus/waiter'
|
5
6
|
|
6
7
|
module Rufus
|
7
8
|
|
@@ -10,38 +11,23 @@ module Rufus
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def exists_after_wait?(view, timeout = 5)
|
13
|
-
wait =
|
14
|
-
|
15
|
-
wait.until{view.exists?}
|
16
|
-
rescue Selenium::WebDriver::Error::TimeOutError
|
17
|
-
return false
|
18
|
-
end
|
19
|
-
true
|
14
|
+
wait = Rufus::Waiter.new selenium, :timeout => timeout
|
15
|
+
wait.until{view.exists?}
|
20
16
|
end
|
21
17
|
|
22
18
|
def displayed_after_wait?(view, timeout = 5)
|
23
|
-
wait =
|
24
|
-
|
25
|
-
wait.until{view.displayed?}
|
26
|
-
rescue Selenium::WebDriver::Error::TimeOutError
|
27
|
-
return false
|
28
|
-
end
|
29
|
-
true
|
19
|
+
wait = Rufus::Waiter.new selenium, :timeout => timeout
|
20
|
+
wait.until{view.displayed?}
|
30
21
|
end
|
31
22
|
|
32
23
|
def enabled_after_wait?(view, timeout = 5)
|
33
|
-
wait =
|
34
|
-
|
35
|
-
wait.until{view.enabled?}
|
36
|
-
rescue Selenium::WebDriver::Error::TimeOutError
|
37
|
-
return false
|
38
|
-
end
|
39
|
-
true
|
24
|
+
wait = Rufus::Waiter.new selenium, :timeout => timeout
|
25
|
+
wait.until{view.enabled?}
|
40
26
|
end
|
41
27
|
|
42
28
|
def enabled_hash_after_wait?(locator, timeout = 5)
|
43
|
-
|
44
|
-
enabled_after_wait?
|
29
|
+
view = Rufus::Accessors::View.new locator
|
30
|
+
enabled_after_wait? view, timeout
|
45
31
|
end
|
46
32
|
|
47
33
|
def exists_hash_after_wait?(locator, timeout = 5)
|
data/lib/rufus/driver.rb
CHANGED
@@ -160,7 +160,12 @@ module Rufus
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def page_source
|
163
|
-
selenium.page_source
|
163
|
+
@page_source = selenium.page_source if @page_source.nil?
|
164
|
+
@page_source
|
165
|
+
end
|
166
|
+
|
167
|
+
def reset_page_source
|
168
|
+
@page_source = nil
|
164
169
|
end
|
165
170
|
|
166
171
|
def all_elements
|
data/lib/rufus/navigation.rb
CHANGED
data/lib/rufus/waiter.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rufus
|
2
|
+
class Waiter
|
3
|
+
|
4
|
+
DEFAULT_TIMEOUT = 5
|
5
|
+
DEFAULT_INTERVAL = 0.2
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(selenium, opts={})
|
9
|
+
@selenium = selenium
|
10
|
+
@timeout = opts.fetch(:timeout, DEFAULT_TIMEOUT)
|
11
|
+
@interval = opts.fetch(:interval, DEFAULT_INTERVAL)
|
12
|
+
end
|
13
|
+
|
14
|
+
def until(&block)
|
15
|
+
time = Time.now + @timeout
|
16
|
+
while Time.now < time
|
17
|
+
@selenium.reset_page_source
|
18
|
+
value = block.call if block
|
19
|
+
return value if value
|
20
|
+
sleep @interval
|
21
|
+
end
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/rufus.gemspec
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rufus/waiter'
|
3
|
+
|
4
|
+
describe Rufus::Waiter do
|
5
|
+
|
6
|
+
let(:view){'mock view'}
|
7
|
+
let(:driver){'mock selenium driver'}
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@waiter = Rufus::Waiter.new driver, :timeout => 0.1, :interval => 0.1
|
11
|
+
driver.should_receive(:reset_page_source)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns false if the block is not true' do
|
15
|
+
view.should_receive(:exists?).and_return(false)
|
16
|
+
@waiter.until{view.exists?}.should be_false
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns true if the block is true' do
|
20
|
+
view.should_receive(:exists?).and_return(true)
|
21
|
+
@waiter.until{view.exists?}.should be_true
|
22
|
+
end
|
23
|
+
end
|
data/spec/navigation_spec.rb
CHANGED
@@ -13,7 +13,10 @@ describe Rufus::Navigation do
|
|
13
13
|
|
14
14
|
context 'getting the active screen' do
|
15
15
|
|
16
|
+
let(:selenium){double('mock selenium driver')}
|
17
|
+
|
16
18
|
before (:each) do
|
19
|
+
selenium.should_receive(:reset_page_source)
|
17
20
|
mock_page.should_receive(:new).and_return(mock_page)
|
18
21
|
end
|
19
22
|
|
data/spec/rufus_spec.rb
CHANGED
@@ -7,81 +7,53 @@ require 'yaml'
|
|
7
7
|
describe Rufus do
|
8
8
|
include Rufus
|
9
9
|
|
10
|
-
|
10
|
+
let(:mock_wait){'mock Rufus::Waiter'}
|
11
|
+
let(:mock_view){'a mock view object'}
|
12
|
+
let(:selenium){double('Selenium::WebDriver')}
|
11
13
|
|
12
|
-
let(:mock_wait){'mock Selenium::WebDriver::Wait'}
|
13
|
-
let(:mock_view){'a mock view object'}
|
14
14
|
|
15
|
+
context 'waiting for an element to exist' do
|
15
16
|
context 'element exists with timeout given' do
|
16
17
|
it 'returns true if an element is found before given timeout occurs' do
|
17
|
-
|
18
|
-
mock_wait.should_receive(:until)
|
19
|
-
exists_after_wait?(mock_view,
|
18
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 1).and_return(mock_wait)
|
19
|
+
mock_wait.should_receive(:until).and_return(true)
|
20
|
+
exists_after_wait?(mock_view, 1).should be_true
|
20
21
|
end
|
21
22
|
it 'returns true if an element is found before default timeout occurs' do
|
22
|
-
|
23
|
-
mock_wait.should_receive(:until)
|
23
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 5).and_return(mock_wait)
|
24
|
+
mock_wait.should_receive(:until).and_return(true)
|
24
25
|
exists_after_wait?(mock_view).should be_true
|
25
26
|
end
|
26
27
|
end
|
27
|
-
context 'element does not exist' do
|
28
|
-
it 'returns false if the timeout is reached' do
|
29
|
-
Selenium::WebDriver::Wait.should_receive(:new).with(:timeout => 5).and_return(mock_wait)
|
30
|
-
mock_wait.should_receive(:until).and_raise(Selenium::WebDriver::Error::TimeOutError)
|
31
|
-
exists_after_wait?(mock_view).should be_false
|
32
|
-
end
|
33
|
-
end
|
34
28
|
end
|
35
29
|
|
36
30
|
context 'waiting for an element to be displayed' do
|
37
|
-
|
38
|
-
let(:mock_wait){'mock Selenium::WebDriver::Wait'}
|
39
|
-
let(:mock_view){'a mock view object'}
|
40
|
-
|
41
31
|
context 'element is displayed with timeout given' do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
32
|
+
it 'returns true if an element is displayed before given timeout occurs' do
|
33
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 1).and_return(mock_wait)
|
34
|
+
mock_wait.should_receive(:until).and_return(true)
|
35
|
+
displayed_after_wait?(mock_view, 1).should be_true
|
36
|
+
end
|
37
|
+
it 'returns true if an element is displayed before default timeout occurs' do
|
38
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 5).and_return(mock_wait)
|
39
|
+
mock_wait.should_receive(:until).and_return(true)
|
40
|
+
displayed_after_wait?(mock_view).should be_true
|
41
|
+
end
|
51
42
|
end
|
52
43
|
end
|
53
|
-
context 'element does not exist' do
|
54
|
-
it 'returns false if the timeout is reached' do
|
55
|
-
Selenium::WebDriver::Wait.should_receive(:new).with(:timeout => 5).and_return(mock_wait)
|
56
|
-
mock_wait.should_receive(:until).and_raise(Selenium::WebDriver::Error::TimeOutError)
|
57
|
-
displayed_after_wait?(mock_view).should be_false
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
44
|
context 'waiting for an element to be enabled' do
|
62
|
-
|
63
|
-
let(:mock_wait){'mock Selenium::WebDriver::Wait'}
|
64
|
-
let(:mock_view){'a mock view object'}
|
65
|
-
|
66
45
|
context 'element is enabled with timeout given' do
|
67
|
-
it 'returns true if an element is
|
68
|
-
|
69
|
-
mock_wait.should_receive(:until)
|
70
|
-
enabled_after_wait?(mock_view,
|
46
|
+
it 'returns true if an element is enabled before given timeout occurs' do
|
47
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 1).and_return(mock_wait)
|
48
|
+
mock_wait.should_receive(:until).and_return(true)
|
49
|
+
enabled_after_wait?(mock_view, 1).should be_true
|
71
50
|
end
|
72
|
-
it 'returns true if an element is enabled before default timeout occurs' do
|
73
|
-
|
74
|
-
mock_wait.should_receive(:until)
|
51
|
+
it 'returns true if an element is not enabled before default timeout occurs' do
|
52
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 5).and_return(mock_wait)
|
53
|
+
mock_wait.should_receive(:until).and_return(true)
|
75
54
|
enabled_after_wait?(mock_view).should be_true
|
76
55
|
end
|
77
56
|
end
|
78
|
-
context 'element does not exist' do
|
79
|
-
it 'returns false if the timeout is reached' do
|
80
|
-
Selenium::WebDriver::Wait.should_receive(:new).with(:timeout => 5).and_return(mock_wait)
|
81
|
-
mock_wait.should_receive(:until).and_raise(Selenium::WebDriver::Error::TimeOutError)
|
82
|
-
enabled_after_wait?(mock_view).should be_false
|
83
|
-
end
|
84
|
-
end
|
85
57
|
end
|
86
58
|
|
87
59
|
context 'elements without accessors' do
|
@@ -113,4 +85,51 @@ describe Rufus do
|
|
113
85
|
scroll_to(:name => 'elementName')
|
114
86
|
end
|
115
87
|
end
|
88
|
+
context 'using locators to find elements not defined with accessors' do
|
89
|
+
|
90
|
+
let(:test_locator){{:name => 'someViewName'}}
|
91
|
+
|
92
|
+
context 'determine if element is enabled' do
|
93
|
+
before(:each) do
|
94
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 5).and_return(mock_wait)
|
95
|
+
Rufus::Accessors::View.should_receive(:new).with(test_locator).and_return(mock_view)
|
96
|
+
end
|
97
|
+
it 'can determine if an element is enabled' do
|
98
|
+
mock_wait.should_receive(:until).and_return(true)
|
99
|
+
enabled_hash_after_wait?(test_locator).should be_true
|
100
|
+
end
|
101
|
+
it 'can determine if an element is not enabled' do
|
102
|
+
mock_wait.should_receive(:until).and_return(false)
|
103
|
+
enabled_hash_after_wait?(test_locator).should be_false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
context 'determine if element is displayed' do
|
107
|
+
before(:each) do
|
108
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 5).and_return(mock_wait)
|
109
|
+
Rufus::Accessors::View.should_receive(:new).with(test_locator).and_return(mock_view)
|
110
|
+
end
|
111
|
+
it 'can determine if an element is enabled' do
|
112
|
+
mock_wait.should_receive(:until).and_return(true)
|
113
|
+
displayed_hash_after_wait?(test_locator).should be_true
|
114
|
+
end
|
115
|
+
it 'can determine if an element is not enabled' do
|
116
|
+
mock_wait.should_receive(:until).and_return(false)
|
117
|
+
displayed_hash_after_wait?(test_locator).should be_false
|
118
|
+
end
|
119
|
+
end
|
120
|
+
context 'determine if element exists by hash' do
|
121
|
+
before(:each) do
|
122
|
+
Rufus::Waiter.should_receive(:new).with(selenium, :timeout => 5).and_return(mock_wait)
|
123
|
+
Rufus::Accessors::View.should_receive(:new).with(test_locator).and_return(mock_view)
|
124
|
+
end
|
125
|
+
it 'can determine if an element is enabled' do
|
126
|
+
mock_wait.should_receive(:until).and_return(true)
|
127
|
+
exists_hash_after_wait?(test_locator).should be_true
|
128
|
+
end
|
129
|
+
it 'can determine if an element is not enabled' do
|
130
|
+
mock_wait.should_receive(:until).and_return(false)
|
131
|
+
exists_hash_after_wait?(test_locator).should be_false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
116
135
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: page_navigation
|
@@ -361,6 +361,7 @@ files:
|
|
361
361
|
- lib/rufus/drivers/iOS_simulator.rb
|
362
362
|
- lib/rufus/navigation.rb
|
363
363
|
- lib/rufus/parser.rb
|
364
|
+
- lib/rufus/waiter.rb
|
364
365
|
- rakefile
|
365
366
|
- rufus.gemspec
|
366
367
|
- spec/accessors_spec.rb
|
@@ -370,6 +371,7 @@ files:
|
|
370
371
|
- spec/drivers_specs/iOS_faster_device_spec.rb
|
371
372
|
- spec/drivers_specs/iOS_faster_simulator_spec.rb
|
372
373
|
- spec/drivers_specs/iOS_simulator_spec.rb
|
374
|
+
- spec/drivers_specs/waiter_spec.rb
|
373
375
|
- spec/navigation_spec.rb
|
374
376
|
- spec/parser_spec.rb
|
375
377
|
- spec/rufus_spec.rb
|