Appium+Pythonモバイルオートメーション【12】:appium+python+pytest+allureメソッドセット
8553 ワード
# toast
def get_toast_content(self, message):
tmp_feature = By.XPATH, "//*[contains(@text,'%s')]" % message
ele = self.find_element(tmp_feature)
return ele.text
#
def take_screenShot(self):
''' , allure '''
tm = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time()))
self.driver.get_screenshot_as_file(
os.getcwd() + os.sep + "image/%s.png" % tm)
allure.attach.file(os.getcwd() + os.sep + "image/%s.png" % tm, attachment_type=allure.attachment_type.PNG)
from appium import webdriver
def init_driver():
desired_caps = {
}
#
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7'
#
desired_caps['deviceName'] = ''
#
desired_caps['appPackage'] = ''
#
desired_caps['appActivity'] = ''
desired_caps['automationName'] = ''
#
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True
desired_caps['autoGrantPermissions'] = True
desired_caps['noReset'] = False
#
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
return driver
import os
from Config import config
from selenium.webdriver.common.by import By
class SplashPageLocators:
"""Splash """
VersionNumber = (By.ID, config.get_infor('Splash_Page')['SplashPage_VersionNumber'])
# os.getcwd()
PATH = os.getcwd()
print(PATH)
if __name__ == "__main__":
A = SplashPageLocators
print(A.VersionNumber)