Files
appium/sample-code/python/test/test_ios_selectors.py
Kazuaki Matsuo cd12ed9a51 Add python sample code (#11208)
* add initial python sample

* add all of ios and android tests

* apply formatter

* add >=0.28 to avoid version error

* tweak versions of default OS

* convert some tests to unittest based ones

* use single quote mainly

* use {} format style for string

* use format syntax

* apply format and tweak assertions

* use is None

* use assert raise

* speficy a number of elements

* tweak exception

* move app path to helper

* tweak assertion conditions

* remove .close since with open() close file automatically
2018-08-22 11:48:58 -07:00

52 lines
1.9 KiB
Python

import pytest
import os
from appium import webdriver
from helpers import take_screenhot_and_syslog, IOS_APP_PATH, EXECUTOR
class TestIOSBasicInteractions():
@pytest.fixture(scope='function')
def driver(self, request, device_logger):
calling_request = request._pyfuncitem.name
driver = webdriver.Remote(
command_executor=EXECUTOR,
desired_capabilities={
'app': IOS_APP_PATH,
'platformName': 'iOS',
'automationName': 'XCUITest',
'platformVersion': os.getenv('IOS_PLATFORM_VERSION') or '11.1',
'deviceName': os.getenv('IOS_DEVICE_NAME') or 'iPhone 6s',
}
)
def fin():
take_screenhot_and_syslog(driver, device_logger, calling_request)
driver.quit()
request.addfinalizer(fin)
driver.implicitly_wait(10)
return driver
def test_should_find_elements_by_accessibility_id(self, driver):
search_parameters_element = driver.find_elements_by_accessibility_id('ComputeSumButton')
assert 1 == len(search_parameters_element)
def test_should_find_elements_by_class_name(self, driver):
window_elements = driver.find_elements_by_class_name('XCUIElementTypeWindow')
assert 2 == len(window_elements)
def test_should_find_elements_by_nspredicate(self, driver):
all_visible_elements = driver.find_elements_by_ios_predicate('visible = 1')
assert 27 == len(all_visible_elements)
def test_should_find_elements_by_class_chain(self, driver):
window_element = driver.find_elements_by_ios_class_chain('XCUIElementTypeWindow[1]/*[2]')
assert 1 == len(window_element)
def test_should_find_elements_by_xpath(self, driver):
action_bar_container_elements = driver.find_elements_by_xpath('//XCUIElementTypeWindow//XCUIElementTypeButton')
assert 8 == len(action_bar_container_elements)