Skip to content

Commit 947fb7f

Browse files
committed
Fix tests for ios_simple , os_complex.
- Change version to 8.3 - Fix according to changes in test application. - Fix path for items
1 parent 159d41c commit 947fb7f

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

sample-code/examples/python/ios_complex.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class ComplexIOSTests(unittest.TestCase):
2222

2323
def setUp(self):
2424
# set up appium
25+
# ** Important Note **
26+
# Make sure you have build the UICatalog applcation in your local repository
2527
app = os.path.join(os.path.dirname(__file__),
2628
'../../apps/UICatalog/build/Release-iphonesimulator',
2729
'UICatalog.app')
@@ -31,7 +33,7 @@ def setUp(self):
3133
desired_capabilities={
3234
'app': app,
3335
'platformName': 'iOS',
34-
'platformVersion': '8.1',
36+
'platformVersion': '8.3',
3537
'deviceName': 'iPhone 6'
3638
})
3739
self._values = []
@@ -55,7 +57,7 @@ def test_find_element(self):
5557
self.assertEqual(18, len(rows))
5658

5759
# is first one about buttons
58-
self.assertEqual(rows[0].get_attribute("name"), "Action Sheets, AAPLActionSheetViewController")
60+
self.assertEqual(rows[0].get_attribute("name"), "Action Sheets")
5961

6062
# there is nav bar inside the app
6163
nav_bar = self.driver.find_element_by_class_name("UIANavigationBar")
@@ -72,7 +74,7 @@ def test_frames(self):
7274

7375
# Find the store link
7476
sleep(4) # let the page load, perhaps
75-
logo = self.driver.find_element_by_id('gn-apple')
77+
logo = self.driver.find_element_by_xpath('//*/UIATextField[@value="http://apple.com"]')
7678
self.assertIsNotNone(logo)
7779

7880
# leave the webview
@@ -86,7 +88,7 @@ def test_location(self):
8688
# get third row location
8789
row = self.driver.find_elements_by_class_name("UIATableCell")[2]
8890
self.assertEqual(row.location['x'], 0)
89-
self.assertEqual(row.location['y'], 152)
91+
self.assertEqual(row.location['y'], 178.8125)
9092

9193
def test_screenshot(self):
9294
# make screenshot and get is as base64
@@ -121,7 +123,7 @@ def test_text_field_edit(self):
121123

122124
def test_alert_interaction(self):
123125
# go to the alerts section
124-
self.driver.find_element_by_name('Alert Views, AAPLAlertViewController').click()
126+
self.driver.find_element_by_name('Alert Views').click()
125127
triggerOk = self.driver.find_element_by_accessibility_id("Simple")
126128

127129
# TOFIX: Looks like alert object is not proper state
@@ -167,7 +169,7 @@ def test_source(self):
167169
# get main view soruce
168170
source_main = self.driver.page_source
169171
self.assertIn("UIATableView", source_main)
170-
self.assertIn("Text Fields, AAPLTextFieldViewController", source_main)
172+
self.assertIn("Text Fields", source_main)
171173

172174
# got to text fields section
173175
self._open_menu_position(13)

sample-code/examples/python/ios_simple.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def setUp(self):
2020
desired_capabilities={
2121
'app': app,
2222
'platformName': 'iOS',
23-
'platformVersion': '8.1',
23+
'platformVersion': '8.3',
2424
'deviceName': 'iPhone 6'
2525
})
2626

@@ -29,7 +29,8 @@ def tearDown(self):
2929

3030
def _populate(self):
3131
# populate text fields with two random numbers
32-
els = self.driver.find_elements_by_ios_uiautomation('elements()')
32+
els = [self.driver.find_element_by_name('TextField1'),
33+
self.driver.find_element_by_name('TextField2')]
3334

3435
self._sum = 0
3536
for i in range(2):
@@ -46,18 +47,21 @@ def test_ui_computation(self):
4647

4748
# is sum equal ?
4849
# sauce does not handle class name, so get fourth element
49-
sum = self.driver.find_element_by_ios_uiautomation('elements()[3]').text
50+
sum = self.driver.find_element_by_name('Answer').text
5051
self.assertEqual(int(sum), self._sum)
5152

5253
def test_scroll(self):
5354
els = self.driver.find_elements_by_class_name('UIAButton')
5455
els[5].click()
5556

5657
sleep(1)
57-
el = self.driver.find_element_by_accessibility_id('OK')
58-
el.click()
58+
try:
59+
el = self.driver.find_element_by_accessibility_id('OK')
60+
el.click()
61+
sleep(1)
62+
except:
63+
pass
5964

60-
sleep(1)
6165
el = self.driver.find_element_by_xpath('//UIAMapView[1]')
6266

6367
location = el.location

0 commit comments

Comments
 (0)