from appium import webdriver
import yaml
import logging
import logging.config
import os

CONLOG='../config/log.conf'
logging.config.fileConfig(CONLOG)
logging=logging.getLogger()

def appium_desired():
    with open('../config/shequ_caps.yaml','r',encoding='utf-8') as file:
        data=yaml.load(file)

    desired_caps={}
    desired_caps['platformName']=data['platformName']
    desired_caps['platformVersion']=data['platformVersion']
    desired_caps['deviceName']=data['deviceName']
    desired_caps['deviceName']=data['deviceName']

    base_dir=os.path.dirname(os.path.dirname(__file__))
    app_path=os.path.join(base_dir,'app',data['appname'])
    desired_caps['app']=app_path

    desired_caps['appPackage']=data['appPackage']
    desired_caps['appActivity']=data['appActivity']
    desired_caps['noReset']=data['noReset']

    desired_caps['unicodeKeyboard'] = data['unicodeKeyboard']
    desired_caps['resetKeyboard'] = data['resetKeyboard']

    logging.info('start app....')
    driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
    driver.implicitly_wait(8)
    return driver

if __name__=='__main__':
    appium_desired()

    





