mirror of
https://github.com/appium/appium.git
synced 2026-01-14 06:10:01 -06:00
* 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
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import pytest
|
|
import os
|
|
|
|
from appium import webdriver
|
|
from helpers import take_screenhot_and_logcat, EXECUTOR
|
|
from selenium.common.exceptions import InvalidSessionIdException
|
|
|
|
|
|
class TestAndroidCreateWebSession():
|
|
|
|
@pytest.fixture(scope='function')
|
|
def driver(self, request, device_logger):
|
|
calling_request = request._pyfuncitem.name
|
|
driver = webdriver.Remote(
|
|
command_executor=EXECUTOR,
|
|
desired_capabilities={
|
|
'platformName': 'Android',
|
|
'automationName': 'UIAutomator2',
|
|
'platformVersion': os.getenv('ANDROID_PLATFORM_VERSION') or '7.1',
|
|
'deviceName': os.getenv('ANDROID_DEVICE_VERSION') or 'Android',
|
|
'browserName': 'Chrome'
|
|
}
|
|
)
|
|
|
|
def fin():
|
|
take_screenhot_and_logcat(driver, device_logger, calling_request)
|
|
|
|
request.addfinalizer(fin)
|
|
|
|
driver.implicitly_wait(10)
|
|
return driver
|
|
|
|
def test_should_create_and_destroy_android_session(self, driver):
|
|
driver.get('https://www.google.com')
|
|
title = driver.title
|
|
|
|
assert 'Google' == title
|
|
|
|
with pytest.raises(InvalidSessionIdException) as excinfo:
|
|
driver.title
|
|
assert 'A session is either terminated or not started' == excinfo.value.msg
|