rufus 0.7 → 0.8

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjU3ODRhOWYwMjMxYmQ3MmM2NGZjYWI3YzhhYWYzM2FmZjA3OWZjYw==
4
+ ZmRlZWRiNzVkYTA5ZWIyNTU1MjhmNWM2OGZjOWE3ZDk3YjNiODhmOA==
5
5
  data.tar.gz: !binary |-
6
- ZDNhNDZhZDAwMGZmYzllNGU1NTI2NTBkOTRkN2ZmOGFiOTcxYmMyYw==
6
+ NzQxZWVhZGFiYjI4NGQ3NDllYTdhMjg5OTZkNmQ0Y2ExOTdlZWU3MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzE0OGFjOTMyMzJkOTczZDYzZjU2ZjkzYmFjMDk1NjQ1Y2UyMmY3ZmVkYmY2
10
- ZGE1NmYyMGY5MWI4MDNmNDkxZGQ2NDMzODc3NmQyY2M1ZjUxYzEwZmZhNGEy
11
- MTgwNjk5NzJjMzVlZDk5ZTA0YjE5OGE0MGVmMGI4NjU5MGJkOTI=
9
+ MTNhY2NjZWYyZjQyZTIzMGVlNmExMDcxMDRlNTUxNGZjMDlkMDJmNGM0YWI5
10
+ NjU0MWJlMTFjMDhjYjMxNWM3OTZmNThkY2I5Y2Q0OWE5Y2U4YzQ1OTdiNGRi
11
+ ZDBmMmM1ZTlkOWM1OWIxOWNiNDAyZmE1MmEyZmZjODdhYjA0MTY=
12
12
  data.tar.gz: !binary |-
13
- NjYzZjNiNDVhMjc2MTBkNWFkNjBhY2VmNjRhZjI3NGNhMDFkZGUxM2JhYjVm
14
- YTg5Zjk4N2I3Njk4MjczMmVjZmY4ZTVhNDkwY2RhNGQzMjkyMWE3OWI5ZDIx
15
- NzIwZGE5ZjE5YmE5Y2NkZWI1YmI1YTJiMjQ1NWY3NTI2Y2I1NjQ=
13
+ NTBlNDhkZGRhMjdkMDM4MWQxM2JlZDgwMmUyMDk4Mzk2NWU5ZWNiMDUyNWJl
14
+ YzA0MDdlMzQ1OTg4NmRlY2IzNjVmMDMzY2UzZTA2ZmYwOWIyMTYzNDJjNjVj
15
+ MDkwZDhlMDFhMzAyN2EyODI4OGE5Nzg3ZDgzOTcyYTZiOTA4NWQ=
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4510" systemVersion="12F45" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES">
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4514" systemVersion="12F45" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES">
3
3
  <dependencies>
4
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
4
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
5
5
  </dependencies>
6
6
  <objects>
7
7
  <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RUViewController">
@@ -21,7 +21,7 @@
21
21
  <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
22
22
  <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23
23
  <subviews>
24
- <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4">
24
+ <button opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4">
25
25
  <rect key="frame" x="270" y="251" width="219" height="30"/>
26
26
  <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
27
27
  <accessibility key="accessibilityConfiguration" label="rufusButton"/>
@@ -32,24 +32,13 @@
32
32
  <action selector="toRufusPage:" destination="-1" eventType="touchUpInside" id="12"/>
33
33
  </connections>
34
34
  </button>
35
- <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="13">
35
+ <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="13">
36
36
  <rect key="frame" x="270" y="209" width="219" height="30"/>
37
37
  <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
38
38
  <accessibility key="accessibilityConfiguration" label="rufusTextBox"/>
39
39
  <fontDescription key="fontDescription" type="system" pointSize="14"/>
40
40
  <textInputTraits key="textInputTraits"/>
41
41
  </textField>
42
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" misplaced="YES" text="Rufus Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="24">
43
- <rect key="frame" x="324" y="180" width="107" height="21"/>
44
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
45
- <accessibility key="accessibilityConfiguration" label="rufusLabel"/>
46
- <constraints>
47
- <constraint firstAttribute="width" constant="219" id="31"/>
48
- </constraints>
49
- <fontDescription key="fontDescription" type="system" pointSize="17"/>
50
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
51
- <nil key="highlightedColor"/>
52
- </label>
53
42
  <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VTc-fX-2Iw">
54
43
  <rect key="frame" x="304" y="302" width="150" height="30"/>
55
44
  <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -117,6 +106,13 @@
117
106
  <action selector="toTablePage:" destination="-1" eventType="touchUpInside" id="hgd-Rn-c0B"/>
118
107
  </connections>
119
108
  </button>
109
+ <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Rufus Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2aB-zP-NHi">
110
+ <rect key="frame" x="333" y="153" width="92" height="21"/>
111
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
112
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
113
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
114
+ <nil key="highlightedColor"/>
115
+ </label>
120
116
  </subviews>
121
117
  <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
122
118
  <constraints>
@@ -124,10 +120,6 @@
124
120
  <constraint firstItem="13" firstAttribute="leading" secondItem="4" secondAttribute="leading" id="17"/>
125
121
  <constraint firstItem="4" firstAttribute="trailing" secondItem="13" secondAttribute="trailing" id="20"/>
126
122
  <constraint firstItem="13" firstAttribute="top" secondItem="2" secondAttribute="top" constant="209" id="23"/>
127
- <constraint firstItem="24" firstAttribute="top" secondItem="2" secondAttribute="top" constant="166" id="25"/>
128
- <constraint firstItem="24" firstAttribute="trailing" secondItem="13" secondAttribute="trailing" id="27"/>
129
- <constraint firstItem="24" firstAttribute="leading" secondItem="13" secondAttribute="leading" id="29"/>
130
- <constraint firstItem="24" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="270" id="30"/>
131
123
  </constraints>
132
124
  <simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="blackOpaque"/>
133
125
  </view>
data/config.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  browser: iOS
2
2
  platform: Mac
3
- version: 7.0
3
+ version: 7.0.3
4
4
  app: ./build/Debug-iphoneos/RufusApp.app
5
5
  udid: 4550a561efc2c047637f342bd6320623ba98c385
6
6
  use_physical: false
7
- sim_app_path: <%=ENV['HOME']%>/Library/Application Support/iPhone Simulator/7.0/Applications/4550a561efc2c047637f342bd6320623ba98c385/RufusApp.app
8
- device: iPhoneSimulator
7
+ sim_app_path: <%=ENV['HOME']%>/Library/Application Support/iPhone Simulator/7.0.3/Applications/4550a561efc2c047637f342bd6320623ba98c385/RufusApp.app
8
+ device: iPhoneSimulator
9
+ optimized: true
@@ -5,7 +5,7 @@ Given(/^I have created a valid appium driver for iOS$/) do
5
5
  config = $driver.config
6
6
  config["browser"].should eq "iOS"
7
7
  config["platform"].should eq "Mac"
8
- config["version"].should eq 7.0
8
+ config["version"].should eq "7.0.3"
9
9
  config["app"].should eq app_path
10
10
  end
11
11
  Given(/^the app is in the "([^"]*)" orientation/) do |orient|
@@ -38,4 +38,10 @@ Then(/^in a block can see the existence of views "([^"]*)", "([^"]*)" and "([^"]
38
38
  screen.send("view_#{view_2}_view").exists?.should be_true
39
39
  screen.send("view_#{view_3}_view").exists?.should be_true
40
40
  end
41
+ end
42
+ Then(/^I can see the view defined "([^"]*)" has text "([^"]*)"$/) do |which, text|
43
+ on(HomePage).send("view_#{which}_view").text.should == text
44
+ end
45
+ Then(/^I can determine the view defined "([^"]*)" is of type "([^"]*)"$/) do |which, type|
46
+ on(HomePage).send("view_#{which}_view").class.should.eql?(type)
41
47
  end
@@ -15,6 +15,7 @@ class HomePage
15
15
  button(:view_tables, :name => 'tablePageButton')
16
16
  button(:alert_Ok, :name => 'Ok')
17
17
  button(:alert_Cancel, :name => 'Cancel')
18
+ label(:view_label, :name => 'Rufus Label')
18
19
 
19
20
 
20
21
  def active?
@@ -36,3 +36,11 @@ Feature: Interacting with views
36
36
  Given I am on the "HomePage"
37
37
  Then in a block can see the existence of views "rufus", "exists" and "displayed"
38
38
 
39
+ Scenario: Getting text of a view
40
+ Given I am on the "HomePage"
41
+ Then I can see the view defined "label" has text "Rufus Label"
42
+
43
+ Scenario: Getting the class of a view
44
+ Given I have created a valid appium driver for iOS
45
+ And I am on the "HomePage"
46
+ Then I can determine the view defined "label" is of type "UIAStaticText"
data/lib/rufus.rb CHANGED
@@ -55,23 +55,23 @@ module Rufus
55
55
  end
56
56
 
57
57
  def find(locator)
58
- selenium.find(locator)
58
+ selenium.send(:driver).find(locator)
59
59
  end
60
60
 
61
61
  def click(locator)
62
- selenium.find(locator).click
62
+ find(locator).click
63
63
  end
64
64
 
65
65
  def page_source
66
- selenium.page_source
66
+ selenium.send(:driver).page_source
67
67
  end
68
68
 
69
69
  def elements_of_type(type)
70
- selenium.elements_by_tag(type)
70
+ selenium.send(:driver).elements_by_tag(type)
71
71
  end
72
72
 
73
73
  def scroll_to(locator)
74
- selenium.scroll_to(locator)
74
+ selenium.send(:driver).scroll_to(locator)
75
75
  end
76
76
  end
77
77
 
@@ -8,32 +8,31 @@ module Rufus
8
8
  end
9
9
 
10
10
  def exists?
11
- element = selenium.find(what)
12
- !element.nil?
11
+ selenium.exists?(what)
13
12
  end
14
13
 
15
14
  def click
16
- selenium.find(what).click
15
+ selenium.click(what)
17
16
  end
18
17
 
19
18
  def displayed?
20
- selenium.find(what).displayed?
19
+ selenium.displayed?(what)
21
20
  end
22
21
 
23
22
  def enabled?
24
- selenium.find(what).enabled?
23
+ selenium.enabled?(what)
25
24
  end
26
25
 
27
26
  def text
28
- selenium.find(what).text
27
+ selenium.text(what)
29
28
  end
30
29
 
31
30
  def send_keys(keys)
32
- selenium.find(what).send_keys keys
31
+ selenium.type(keys, what[:name])
33
32
  end
34
33
 
35
34
  def class
36
- selenium.find(what).tag_name
35
+ selenium.class(what)
37
36
  end
38
37
 
39
38
  def what
data/lib/rufus/driver.rb CHANGED
@@ -1,66 +1,62 @@
1
1
  require 'yaml'
2
- require 'rufus/drivers/iOS_device'
3
- require 'rufus/drivers/iOS_simulator'
4
- require 'selenium-webdriver'
5
2
  require 'erb'
6
- require 'selenium/webdriver/safari/extension'
3
+ require 'rufus/drivers/driver_factory'
7
4
 
8
5
  module Rufus
9
6
  class Driver
10
7
 
8
+ attr_reader :config
9
+ attr_reader :url
10
+
11
11
  def initialize
12
12
  raise 'No config.yml found' if !File.exists?('config.yml')
13
13
  @config = YAML.load(ERB.new(File.read('config.yml')).result)
14
- @url = url(@config)
14
+ driver
15
15
  end
16
16
 
17
17
  def start
18
- driver.get @url
18
+ driver.start
19
19
  end
20
20
 
21
21
  def quit
22
22
  driver.quit
23
- @selenium = nil
24
- end
25
-
26
- def config
27
- @config
28
- end
29
-
30
- def server_url
31
- @url
23
+ @selenium_driver = nil
32
24
  end
33
25
 
34
26
  def find(locator)
35
- how = locator.keys[0].to_sym
36
- what = locator[how]
37
- begin
38
- driver.find_element(how, what)
39
- rescue Selenium::WebDriver::Error::NoSuchElementError
40
- return nil
41
- end
27
+ driver.find(locator)
42
28
  end
43
29
 
44
30
  def cells(locator)
45
- element = find(locator)
46
- raise 'Expected view to be of type UIATableView' unless element.tag_name.eql? 'UIATableView'
47
- element.find_elements(:tag_name, 'UIATableCell')
31
+ driver.cells(locator)
32
+ end
33
+
34
+ def exists?(locator)
35
+ driver.exists?(locator)
48
36
  end
49
37
 
50
38
  def click(locator)
51
- find(locator).click
39
+ driver.click(locator)
52
40
  end
53
41
 
54
42
  def press_button name
55
- click(:name => name)
43
+ driver.press_button name
56
44
  end
57
45
 
58
46
  def enabled?(locator)
59
- find(locator).enabled?
47
+ driver.enabled?(locator)
60
48
  end
61
49
 
62
50
  def displayed?(locator)
63
- find(locator).displayed?
51
+ driver.displayed?(locator)
52
+ end
53
+
54
+ def text(locator)
55
+ driver.text(locator)
56
+ end
57
+
58
+ def class(locator)
59
+ driver.class(locator)
64
60
  end
65
61
 
66
62
  def orientation
@@ -72,87 +68,47 @@ module Rufus
72
68
  end
73
69
 
74
70
  def type(keys, name)
75
- element = find(:name => name)
76
- element.click
77
- sleep 1
78
- element.send_keys keys
71
+ driver.type(keys, name)
79
72
  end
80
73
 
81
74
  def sequence(*names, times)
82
- timed_sequence(names, times, 1)
75
+ driver.sequence(names, times, 1)
83
76
  end
84
77
 
85
78
  def buttons
86
- buttons = []
87
- elements = elements_by_tag 'UIAButton'
88
- elements.each do |element|
89
- buttons << element.text
90
- end
91
- buttons
79
+ driver.buttons
92
80
  end
93
81
 
94
82
  def text_fields
95
- fields = []
96
- elements = elements_by_tag 'UIATextField'
97
- elements.each do |element|
98
- fields << element.text
99
- end
100
- fields
83
+ driver.text_fields
101
84
  end
102
85
 
103
86
  def labels
104
- labels = []
105
- elements = elements_by_tag 'UIAStaticText'
106
- elements.each do |element|
107
- labels << element.text
108
- end
109
- labels
87
+ driver.labels
110
88
  end
111
89
 
112
90
  def timed_sequence(names, times, seconds)
113
- current = 0
114
- until current == times
115
- names.each do |name|
116
- click(:name => name)
117
- sleep seconds
118
-
119
- end
120
- current += 1
121
- puts "sequence #{current} completed"
122
- end
91
+ driver.timed_sequence(names, times, seconds)
123
92
  end
124
93
 
125
94
  def find_alert(locator)
126
- alert = nil
127
- all_elements.each do |element|
128
- if is_alert?(element)
129
- alert = element if match?(element, locator[:name])
130
- end
131
- end
132
- alert
95
+ driver.find_alert(locator)
133
96
  end
134
97
 
135
98
  def click_alert(button)
136
- if alert_shown?
137
- click_alert_button(button)
138
- end
99
+ driver.click_alert(button)
139
100
  end
140
101
 
141
102
  def alert_shown?
142
- all_elements.each do |element|
143
- if is_alert?(element)
144
- return true
145
- end
146
- end
147
- false
103
+ driver.alert_shown?
148
104
  end
149
105
 
150
106
  def class_for(element)
151
- element.tag_name
107
+ driver.class_for(element)
152
108
  end
153
109
 
154
110
  def match?(element, name)
155
- element.attribute(:name).eql? name
111
+ driver.match?
156
112
  end
157
113
 
158
114
  def page_source
@@ -160,56 +116,23 @@ module Rufus
160
116
  end
161
117
 
162
118
  def all_elements
163
- elements_by_tag('UIAElement')
119
+ driver.all_elements
164
120
  end
165
121
 
166
122
  def elements_by_tag(name)
167
- driver.find_elements(:tag_name, name)
123
+ driver.elements_by_tag name
168
124
  end
169
125
 
170
126
  def scroll_to(locator)
171
- id = find(locator).ref
172
- driver.execute_script 'mobile: scrollTo', {'element' => id}
127
+ driver.scroll_to(locator)
173
128
  end
174
129
 
175
130
  def screenshot(name)
176
- driver.save_screenshot name
177
- end
178
-
179
- private
180
-
181
- def url(config)
182
- if config["appium_url"].nil? || config["appium_url"].eql?("")
183
- 'http://127.0.0.1:4723/wd/hub'
184
- else
185
- config["appium_url"]
186
- end
187
- end
188
-
189
- def click_alert_button(button)
190
- all_elements.each do |element|
191
- element.click if is_table_view_cell?(element) && match?(element, button)
192
- end
193
- end
194
-
195
- def is_alert?(element)
196
- class_for(element).eql?('UIAAlert')
197
- end
198
-
199
- def is_table_view_cell?(element)
200
- class_for(element).eql?('UIATableCell')
131
+ driver.screenshot name
201
132
  end
202
133
 
203
134
  def driver
204
- if use_device
205
- @selenium ||= Rufus::Drivers::IOS_Device.for(@config,@url)
206
- else
207
- @selenium ||= Rufus::Drivers::IOS_Simulator.for(@config,@url)
208
- end
209
- end
210
-
211
- def use_device
212
- @config["use_physical"] == true
135
+ @selenium_driver ||= Rufus::Drivers::DriverFactory.driver_for(@config)
213
136
  end
214
137
  end
215
138
  end