Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified test/apps/UICatalog.app.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion test/functional/android/helper/desired_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_desired_capabilities(app):
desired_caps = {
'platformName': 'Android',
'deviceName': 'Android Emulator',
'app': PATH('../../apps/' + app),
'app': PATH('../../apps/{}'.format(app)),
'newCommandTimeout': 240,
'automationName': 'UIAutomator2'
}
Expand Down
57 changes: 29 additions & 28 deletions test/functional/ios/appium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import unittest
from time import sleep

import desired_capabilities
from appium import webdriver
from appium.webdriver.applicationstate import ApplicationState
from appium.webdriver.common.mobileby import MobileBy
from helper import desired_capabilities


class AppiumTests(unittest.TestCase):
Expand All @@ -38,7 +39,7 @@ def test_lock(self):

def test_screen_record(self):
self.driver.start_recording_screen()
sleep(5)
sleep(10)
result = self.driver.stop_recording_screen()
self.assertTrue(len(result) > 0)

Expand Down Expand Up @@ -70,11 +71,9 @@ def test_toggle_touch_id_enrollment(self):
self.driver.toggle_touch_id_enrollment()

def test_hide_keyboard(self):
el = self.driver.find_element_by_name('Uses of UITextField')
el.click()
self._move_to_textbox()

# get focus on text field, so keyboard comes up
el = self.driver.find_element_by_class_name('UIATextField')
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
el.set_value('Testing')

el = self.driver.find_element_by_class_name('UIAKeyboard')
Expand All @@ -85,11 +84,9 @@ def test_hide_keyboard(self):
self.assertFalse(el.is_displayed())

def test_hide_keyboard_presskey_strategy(self):
el = self.driver.find_element_by_name('Uses of UITextField')
el.click()
self._move_to_textbox()

# get focus on text field, so keyboard comes up
el = self.driver.find_element_by_class_name('UIATextField')
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
el.set_value('Testing')

el = self.driver.find_element_by_class_name('UIAKeyboard')
Expand All @@ -100,11 +97,9 @@ def test_hide_keyboard_presskey_strategy(self):
self.assertFalse(el.is_displayed())

def test_hide_keyboard_no_key_name(self):
el = self.driver.find_element_by_name('Uses of UITextField')
el.click()
self._move_to_textbox()

# get focus on text field, so keyboard comes up
el = self.driver.find_element_by_class_name('UIATextField')
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
el.set_value('Testing')

el = self.driver.find_element_by_class_name('UIAKeyboard')
Expand All @@ -117,33 +112,31 @@ def test_hide_keyboard_no_key_name(self):
self.assertFalse(el.is_displayed())

def test_is_keyboard_shown(self):
self.assertFalse(self.driver.is_keyboard_shown())
el = self.driver.find_element_by_name('Uses of UITextField')
el.click()
self._move_to_textbox()

# get focus on text field, so keyboard comes up
el = self.driver.find_element_by_class_name('UIATextField')
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
el.set_value('Testing')
self.assertTrue(self.driver.is_keyboard_shown())

def test_clear(self):
# Click text fields
self.driver.find_element_by_accessibility_id('TextFields').click()
self._move_to_textbox()

el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]

# Verify default text
def_text = '<enter text>'
text = self.driver.find_element_by_accessibility_id('Normal').get_attribute('value')
def_text = 'Placeholder text'
text = el.get_attribute('value')
self.assertEqual(text, def_text)

# Input some text, verify
input_text = 'blah'
self.driver.find_element_by_accessibility_id('Normal').send_keys(input_text)
text = self.driver.find_element_by_accessibility_id('Normal').get_attribute('value')
el.send_keys(input_text)
text = el.get_attribute('value')
self.assertEqual(text, input_text)

# Clear text, verify
self.driver.find_element_by_accessibility_id('Normal').clear()
text = self.driver.find_element_by_accessibility_id('Normal').get_attribute('value')
el.clear()
text = el.get_attribute('value')
self.assertEqual(text, def_text)

def test_press_button(self):
Expand All @@ -154,7 +147,15 @@ def test_press_button(self):
self.assertEqual(self.driver.query_app_state(desired_capabilities.BUNDLE_ID),
ApplicationState.RUNNING_IN_FOREGROUND)

def _move_to_textbox(self):
el1 = self.driver.find_element_by_accessibility_id('Sliders')
el2 = self.driver.find_element_by_accessibility_id('Buttons')
self.driver.scroll(el1, el2)

# Click text fields
self.driver.find_element_by_accessibility_id('Text Fields').click()


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)
unittest.TextTestRunner(verbosity=2).run(suite)
10 changes: 5 additions & 5 deletions test/functional/ios/find_by_element_webelement_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import unittest

import desired_capabilities
from appium import webdriver
from helper import desired_capabilities


class FindByElementWebelementTests(unittest.TestCase):
Expand All @@ -33,16 +33,16 @@ def test_find_element_by_path(self):
el = self.driver.find_element_by_ios_predicate('wdName == "UICatalog"')
self.assertEqual('UICatalog', el.get_attribute('name'))

c_el = el.find_elements_by_ios_predicate('label == "TextFields"')
self.assertEqual('TextFields', c_el[0].get_attribute('name'))
c_el = el.find_elements_by_ios_predicate('label == "Action Sheets"')
self.assertEqual('Action Sheets', c_el[0].get_attribute('name'))

c_el = el.find_elements_by_ios_class_chain('**/XCUIElementTypeStaticText')
self.assertEqual('UICatalog', c_el[0].get_attribute('name'))
self.assertEqual('Action Sheets', c_el[0].get_attribute('name'))

c_el = el.find_elements_by_accessibility_id('UICatalog')
self.assertEqual('UICatalog', c_el[0].get_attribute('name'))


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FindByElementWebelementTests)
unittest.TextTestRunner(verbosity=2).run(suite)
6 changes: 3 additions & 3 deletions test/functional/ios/find_by_ios_class_chain_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import unittest

import desired_capabilities
from appium import webdriver
from helper import desired_capabilities


class FindByIOClassChainTests(unittest.TestCase):
Expand All @@ -30,7 +30,7 @@ def tearDownClass(self):

def test_find_element_by_path(self):
el = self.driver.find_element_by_ios_class_chain('XCUIElementTypeWindow/**/XCUIElementTypeStaticText')
self.assertEqual('UICatalog', el.get_attribute('name'))
self.assertEqual('Action Sheets', el.get_attribute('name'))

def test_find_multiple_elements_by_path(self):
el = self.driver.find_elements_by_ios_class_chain('XCUIElementTypeWindow/*/*/*')
Expand All @@ -39,6 +39,6 @@ def test_find_multiple_elements_by_path(self):
self.assertEqual(None, el[1].get_attribute('name'))


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FindByIOClassChainTests)
unittest.TextTestRunner(verbosity=2).run(suite)
16 changes: 8 additions & 8 deletions test/functional/ios/find_by_ios_predicate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import unittest

import desired_capabilities
from appium import webdriver
from helper import desired_capabilities


class FindByIOSPredicateTests(unittest.TestCase):
Expand All @@ -38,29 +38,29 @@ def test_find_multiple_element_by_type(self):

def test_find_element_by_label(self):
# Will throw exception if element is not found
self.driver.find_element_by_ios_predicate('label == "TextFields"')
self.driver.find_element_by_ios_predicate('label == "Buttons"')

def test_find_element_by_value(self):
# Will throw exception if element is not found
self.driver.find_element_by_ios_predicate('wdValue == "Controls"')
self.driver.find_element_by_ios_predicate('wdValue == "Buttons"')

def test_find_element_by_isvisible(self):
# Will throw exception if element is not found
self.driver.find_element_by_ios_predicate('wdValue == "SearchBar" AND isWDVisible == 1')
self.driver.find_element_by_ios_predicate('wdValue == "Buttons" AND visible == 1')

# Should not find any elements
e = self.driver.find_elements_by_ios_predicate('wdValue == "SearchBar" AND isWDVisible == 0')
e = self.driver.find_elements_by_ios_predicate('wdValue == "Buttons" AND visible == 0')
self.assertEqual(len(e), 0)

def test_find_element_by_isenabled(self):
# Will throw exception if element is not found
self.driver.find_element_by_ios_predicate('wdValue == "SearchBar" AND isWDEnabled == 1')
self.driver.find_element_by_ios_predicate('wdValue == "Buttons" AND enabled == 1')

# Should not find any elements
e = self.driver.find_elements_by_ios_predicate('wdValue == "SearchBar" AND isWDEnabled == 0')
e = self.driver.find_elements_by_ios_predicate('wdValue == "Buttons" AND enabled == 0')
self.assertEqual(len(e), 0)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(FindByIOSPredicateTests)
unittest.TextTestRunner(verbosity=2).run(suite)
56 changes: 0 additions & 56 deletions test/functional/ios/find_by_uiautomation_tests.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def get_desired_capabilities(app):
desired_caps = {
'deviceName': iphone_device_name(),
'platformName': 'iOS',
'platformVersion': '12.1',
'app': PATH('../../apps/' + app),
'platformVersion': '12.2',
'app': PATH('../../../apps/{}'.format(app)),
'automationName': 'XCUITest',
'allowTouchIdEnroll': True,
'wdaLocalPort': wda_port(),
Expand Down
6 changes: 3 additions & 3 deletions test/functional/ios/push_file_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import os
import unittest

import desired_capabilities
from appium import webdriver
from helper import desired_capabilities


class PushFileTests(unittest.TestCase):
Expand All @@ -31,12 +31,12 @@ def tearDownClass(self):

def test_push_file(self):
file_name = 'test_image.jpg'
source_path = os.path.dirname(os.path.abspath(__file__)) + '/' + file_name
source_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'file', file_name)
destination_path = file_name

self.driver.push_file(destination_path, source_path=source_path)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(PushFileTests)
unittest.TextTestRunner(verbosity=2).run(suite)
13 changes: 7 additions & 6 deletions test/functional/ios/safari_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python

import unittest
from time import sleep

from appium import webdriver

Expand All @@ -11,25 +10,27 @@ def setUp(self):
desired_caps = {
'browserName': 'safari',
'platformName': 'iOS',
'platformVersion': '7.1',
'platformVersion': '12.2',
'deviceName': 'iPhone Simulator',
'nativeWebTap': True,
'safariIgnoreFraudWarning': True
'safariIgnoreFraudWarning': True,
'automationName': 'XCUITest'
}
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

def tearDown(self):
self.driver.quit()

def test_context(self):
self.assertEqual([u'NATIVE_APP', u'WEBVIEW_1'], self.driver.contexts)
self.assertEqual('WEBVIEW_1', self.driver.current_context)
self.assertEqual('NATIVE_APP', self.driver.contexts[0])
self.assertTrue(self.driver.contexts[1].startswith('WEBVIEW_'))
self.assertTrue('WEBVIEW_' in self.driver.current_context)

def test_get(self):
self.driver.get("http://google.com")
self.assertEqual('Google', self.driver.title)


if __name__ == "__main__":
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(SafariTests)
unittest.TextTestRunner(verbosity=2).run(suite)