#coding=utf-8
from appium import webdriver
from selenium.webdriver.common.keys import Keys
from appium.webdriver.webdriver import WebDriverWait
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.switch_to import MobileSwitchTo
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
op = {}
op['platformName'] = 'Android'
op['deviceName'] = 'Android Emulator'
op['appPackage'] = 'com.sina.book'
op['appActivity'] = '.ui.activity.splash.SplashActivity'
op['unicodeKeyboard'] = True
op['resetKeyboard'] = True
op['newCommandTimeout'] = 10
op['noReset'] = True
driver = webdriver.Remote('http://localhost:4723/wd/hub,op')
WebDriverWait(driver, 10).until(EC.presence_of_element_located((MobileBy.XPATH,'//android.widget.TextView[@text="书城"]')))
driver.find_element_by_xpath('//android.widget.TextView[@text="书城"]').click()
driver.switch_to.context('WEBVIEW')
driver.find_element_by_css_selector('.main-nav > a:nth-child(1)').click()