mirror of
https://github.com/appium/appium.git
synced 2026-01-23 19:00:31 -06:00
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
This commit is contained in:
committed by
Dan Graham
parent
649c5d43d7
commit
cd12ed9a51
47
sample-code/python/test/test_ios_basic_interactions.py
Normal file
47
sample-code/python/test/test_ios_basic_interactions.py
Normal file
@@ -0,0 +1,47 @@
|
||||
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_send_keys_to_inputs(self, driver):
|
||||
text_field_el = driver.find_element_by_id('TextField1')
|
||||
assert text_field_el.get_attribute('value') is None
|
||||
text_field_el.send_keys('Hello World!')
|
||||
assert 'Hello World!' == text_field_el.get_attribute('value')
|
||||
|
||||
def test_should_click_a_button_that_opens_an_alert(self, driver):
|
||||
button_element_id = 'show alert'
|
||||
button_element = driver.find_element_by_accessibility_id(button_element_id)
|
||||
button_element.click()
|
||||
|
||||
alert_title_element_id = 'Cool title'
|
||||
alert_title_element = driver.find_element_by_accessibility_id(alert_title_element_id)
|
||||
alert_title = alert_title_element.get_attribute('name')
|
||||
assert 'Cool title' == alert_title
|
||||
Reference in New Issue
Block a user