コード例 #1
0
def loginApp(driver):
    pwdPath = '//android.widget.Button[@content-desc="login-trade-input-pwd"]'
    driver.find_element_by_xpath(pwdPath).click()
    sleep(1)
    pwd = getPwd('yiTaoJin')['tradePwd']
    getKeyCode(driver, pwd)
    sleep(1)
コード例 #2
0
def loginApp(driver, buyCodePath):
    typePath = '/hierarchy/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button[2]'
    if isExist(driver, 2, typePath):
        driver.find_element_by_xpath(typePath).click()
        sleep(1)
        pwdPath = '/hierarchy/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout[1]/android.widget.EditText'
        driver.find_element_by_xpath(pwdPath).click()
        sleep(1)
        pwd = getPwd('fangDe')['logInPwd']
        getKeyCode(driver, pwd)
        sleep(1)
        loginPath = '/hierarchy/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button'
        driver.find_element_by_xpath(loginPath).click()
        sleep(1)
        agreePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button[2]'
        driver.find_element_by_xpath(agreePath).click()
        sleep(1)
        driver.find_element_by_xpath(buyCodePath).click()
        sleep(1)
    tradePwdPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.EditText'
    if isExist(driver, 2, tradePwdPath):
        driver.find_element_by_xpath(tradePwdPath).click()
        sleep(1)
        pwd = getPwd('fangDe')['tradePwd']
        getKeyCode(driver, pwd)
        sleep(1)
        loginPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button'
        driver.find_element_by_xpath(loginPath).click()
        sleep(1)
コード例 #3
0
def buyHuiLi(param):
    code = param['code']
    isCash = param['isCash']
    stockNumVal = param['numVal']
    isFinancingAll = param['isFinancingAll']
    isCashAll = param['isCashAll']
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.hk.poems.poemsMobileFX'
    settingData['appActivity'] = 'PoemsMobileTabActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    accountPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.TabHost/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[2]/android.widget.EditText[1]'
    driver.find_element_by_xpath(accountPath).clear()
    driver.find_element_by_xpath(accountPath).click()
    acount = getPwd('huiLi')['account']
    getKeyCode(driver, acount)
    sleep(1)
    pwdPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.TabHost/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[2]/android.widget.EditText[2]'
    driver.find_element_by_xpath(pwdPath).click()
    pwd = getPwd('huiLi')['logInPwd']
    getKeyCode(driver, pwd)
    sleep(1)
    loginPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.TabHost/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[4]/android.widget.LinearLayout[1]/android.widget.Button[2]'
    driver.find_element_by_xpath(loginPath).click()
    sleep(5)
    confirmKeyPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.Button'
    driver.find_element_by_xpath(confirmKeyPath).click()
    sleep(1)
    print(driver.page_source)
    keyPath = '/hierarchy/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.ImageButton'
    driver.find_element_by_xpath(keyPath).click()
    sleep(1)
    copyKeyPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.TextView'
    driver.find_element_by_xpath(copyKeyPath).click()
    sleep(1)
    confirmCopyPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button[1]'
    driver.find_element_by_xpath(confirmCopyPath).click()
    sleep(5)
    acceptPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.Button[1]'
    driver.find_element_by_xpath(acceptPath).click()
    sleep(5)
    # driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click()
    # sleep(1)
    # driver.find_element_by_android_uiautomator('new UiSelector().text("认购新股")').click()
    # sleep(1)

    sleep(10)
コード例 #4
0
ファイル: changQiao.py プロジェクト: DuffyWang926/getStockApp
def buyChangQiao(param):
    code = param['code']
    codeName = param['codeName']
    isCash = param['isCash']
    stockNumVal = param['numVal']
    isFinancingAll = param['isFinancingAll']
    isCashAll = param['isCashAll']
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'global.longbridge.app.android'
    settingData['appActivity'] = 'global.longbridge.android.LaunchActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("市场")').click()
    sleep(1)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("IPO 专区")').click()
    sleep(1)
    print(driver.page_source)
    codeListPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View[5]/android.widget.ListView'
    codeList = driver.find_elements_by_xpath(codeListPath)
    codeListLen = len(codeList)
    if codeListLen < 2:
        codeNameTextPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View[5]/android.widget.ListView/android.view.View/android.view.View/android.view.View[2]/android.view.View[2]/android.widget.TextView'
        codeNameText = driver.find_element_by_xpath(codeNameTextPath).text
        print(codeNameText)
        if codeName in codeNameText:
            codeBuyPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View[5]/android.widget.ListView/android.view.View/android.view.View/android.view.View[3]/android.widget.Button'
            driver.find_element_by_xpath(codeBuyPath).click()
            sleep(1)
    pwd = getPwd('changQiao')['tradePwd']
    getKeyCode(driver, pwd)
    sleep(1)
    numChoosePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[2]/android.view.View[2]/android.view.View[1]'
    driver.find_element_by_xpath(numChoosePath).click()
    sleep(1)
    if isFinancingAll:
        choosePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[2]/android.view.View[6]/android.widget.Button[2]'
    else:
        choosePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[2]/android.view.View[6]/android.widget.Button[1]'
    driver.find_element_by_xpath(choosePath).click()
    sleep(1)
    confirmPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[5]/android.view.View[3]/android.widget.Button'
    driver.find_element_by_xpath(confirmPath).click()
    sleep(1)
    driver.quit()
コード例 #5
0
ファイル: fuYuan.py プロジェクト: DuffyWang926/getStockApp
def buyFuYuan(param):
    code = param['code']
    isCash = param['isCash']
    stockNumVal = param['numVal']
    isFinancingAll = param['isFinancingAll']
    isCashAll = param['isCashAll']
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.sunline.android.sunline'
    settingData['appActivity'] = '.DefaultAlias'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    if isExist(driver, 4, 'com.sunline.android.sunline:id/cancel'):
        driver.find_element_by_id(
            'com.sunline.android.sunline:id/cancel').click()
        sleep(1)
    tipPath = 'new UiSelector().text("我知道了")'
    if isExist(driver, 1, tipPath):
        driver.find_element_by_android_uiautomator(tipPath).click()
        sleep(1)

    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("交易")').click()
    sleep(2)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("新股认购")').click()
    sleep(1)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("可认购")').click()
    sleep(1)
    # contentPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup/android.widget.LinearLayout[2]/android.support.v4.view.ViewPager/android.widget.ScrollView/android.widget.ViewSwitcher/android.widget.RelativeLayout/android.support.v7.widget.RecyclerView/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout'
    # contentView = driver.find_element_by_xpath(contentPath)
    titlePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup/android.widget.LinearLayout[2]/android.support.v4.view.ViewPager/android.widget.ScrollView/android.widget.ViewSwitcher/android.widget.RelativeLayout/android.support.v7.widget.RecyclerView/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.TextView[2]'
    title = driver.find_element_by_xpath(titlePath).text
    if code in title:
        buyPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup/android.widget.LinearLayout[2]/android.support.v4.view.ViewPager/android.widget.ScrollView/android.widget.ViewSwitcher/android.widget.RelativeLayout/android.support.v7.widget.RecyclerView/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.Button'
        driver.find_element_by_xpath(buyPath).click()
        sleep(1)
    pwd = getPwd('fuYuan')['tradePwd']
    getKeyCode(driver, pwd)
    confirmId = 'com.sunline.android.sunline:id/btn_purchase'
    end = driver.find_element_by_id(confirmId).text
    print(end)

    sleep(20)
    driver.quit()
コード例 #6
0
ファイル: ruiFeng.py プロジェクト: DuffyWang926/getStockApp
def loginApp(driver, *others):
    pwdPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.EditText'
    if isExist(driver, 2, pwdPath):
        driver.find_element_by_xpath(pwdPath).click()
        sleep(1)
        pwd = getPwd('ruiFeng')['logInPwd']
        getKeyCode(driver, pwd)
        sleep(1)
        confirmPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.Button'
        driver.find_element_by_xpath(confirmPath).click()
        sleep(2)
    if others:
        lastPath = others[0]
        if isExist(driver, 2, lastPath):
            driver.find_element_by_xpath(lastPath).click()
            sleep(1)
コード例 #7
0
def tradeFuTu(param):
    driver = initFuTu(param)
    searchPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.LinearLayoutCompat/android.widget.FrameLayout[2]/android.widget.ImageView'
    if not isExist(driver, 2, searchPath):
        searchPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.support.v7.widget.LinearLayoutCompat/android.widget.FrameLayout[1]/android.widget.ImageView'
    driver.find_element_by_xpath(searchPath).click()
    sleep(1)
    code = param['code']
    getKeyCode(driver, code)
    sleep(4)
    recordFlag = True
    while recordFlag:
        stockPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout/android.view.ViewGroup/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.view.ViewGroup/android.support.v7.widget.RecyclerView/android.view.ViewGroup'
        driver.find_element_by_xpath(stockPath).click()
        sleep(1)
        recordFlag = recordPrice(driver, param)
    sleep(10)
コード例 #8
0
def getkey(param):
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.guodu.token'
    settingData[
        'appActivity'] = 'md58eeaaf6ecd101572fa448c5104fa33aa.BrokerListActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(6)
    pwd = getPwd('guoDu')['tradePwd']
    getKeyCode(driver, pwd)
    sleep(3)
    print(driver.page_source)
    driver.get_screenshot_as_file('./guodu.png')
    # screenshotBase64 = driver.get_screenshot_as_base64()
    # print(screenshotBase64)
    # keyLeftPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.TextView[1]'
    # keyLeftId = 'com.guodu.token:id/token_left_textview'
    # # keyLeft = driver.find_element_by_xpath(keyLeftPath).text
    # keyLeft = driver.find_element_by_id(keyLeftId).text
    # print(keyLeft)
    # keyRightPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.TextView[2]'
    # keyRightId = 'com.guodu.token:id/token_right_textview'
    # # keyRight = driver.find_element_by_xpath(keyRightPath).text
    # keyRight = driver.find_element_by_xpath(keyRightId).text
    # print(keyRight)
    # key = keyLeft + keyRight
    # print(key)
    # timePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.RelativeLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout/android.widget.TextView'
    # timeId = 'com.guodu.token:id/sec_textview'
    # time = driver.find_element_by_xpath(timeId).text
    # # time = driver.find_element_by_xpath(timePath).text
    # print(time)

    keyListPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.RelativeLayout/android.widget.LinearLayout[1]/android.widget.TextView'
    keyList = driver.find_elements_by_xpath(keyListPath)
    print(len(keyList))
    for i in keyList:
        text = i.text
        print(text)
コード例 #9
0
ファイル: yiSheng.py プロジェクト: DuffyWang926/getStockApp
def loginApp(driver, buyCodePath):
    namePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]/android.widget.EditText'
    nameText = driver.find_element_by_xpath(namePath).text
    pwdPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[2]/android.widget.EditText'
    driver.find_element_by_xpath(pwdPath).click()
    sleep(1)
    account = getPwd('yiSheng')['account']
    if account in nameText:
        pwd = getPwd('yiSheng')['tradePwd']
        getKeyCode(driver, pwd)
        sleep(1)
        loginPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button'
        driver.find_element_by_xpath(loginPath).click()
        sleep(1)
    else:
        pwd = getPwd('yiSheng')['logInPwd']
        getKeyCode(driver, pwd)
        sleep(1)
        loginPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button'
        driver.find_element_by_xpath(loginPath).click()
        sleep(1)
        driver.find_element_by_xpath(buyCodePath).click()
        sleep(1)
        pwd = getPwd('yiSheng')['tradePwd']
        getKeyCode(driver, pwd)
        sleep(1)
        loginPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.Button'
        driver.find_element_by_xpath(loginPath).click()
        sleep(1)
    driver.find_element_by_xpath(buyCodePath).click()
    sleep(1)
コード例 #10
0
def buyDongCai(param):
    code = param['code']
    isCash = param['isCash']
    stockNum = param['num']
    # stockNumVal = param['numVal']
    isFinancingAll = param['isFinancingAll']
    isCashAll = param['isCashAll']
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.eastmoney.android.lead'
    settingData[
        'appActivity'] = 'com.eastmoney.android.berlin.activity.MainActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://*****:*****@text, "认购中")]').click()
    sleep(1)
    codeText = 'new UiSelector().text("' + code + '")'
    codeParentView = driver.find_element_by_android_uiautomator(
        codeText).parent
    codeParentView.find_element_by_android_uiautomator(
        'new UiSelector().text("认购")').click()
    sleep(1)
    pwd = getPwd('dongCai')['tradePwd']
    print(pwd)
    getKeyCode(driver, pwd)
    sleep(3)
    if isCash:
        cashText = 'new UiSelector().text("现金")'
        driver.find_element_by_android_uiautomator(cashText).click()
    amountChooseUi = 'new UiSelector().text("请选择认购股数")'
    driver.find_element_by_android_uiautomator(amountChooseUi).click()
    sleep(1)

    amountFlag = True
    amountCheckIndex = ''
    while amountFlag:
        amountViewPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup'
        amountView = driver.find_elements_by_xpath(amountViewPath)
        amountLen = len(amountView) - 1
        print(amountLen)
        for i in range(amountLen):
            index = str(i + 1)
            print(index)
            if isCashAll:
                amountOutText = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[' + index + ']/android.view.ViewGroup/android.widget.TextView[2]'
                if isExist(driver, 2, amountOutText):
                    amountFlag = False
                    amountCheckIndex = str(i)
                    break
            elif isCash:
                amountTextPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[' + index + ']/android.view.ViewGroup/android.widget.TextView'
                amountText = driver.find_element_by_xpath(amountTextPath).text
                if stockNum in amountText:
                    amountFlag = False
                    amountCheckIndex = str(i + 1)
                    break
            elif isFinancingAll:
                testUi = 'new UiSelector().textContains("不足")'
                if isExist(amountView[i], 1, testUi):
                    test = amountView[i].find_element_by_android_uiautomator(
                        'new UiSelector().textContains("不足")').text
                    print(test)
                    amountFlag = False
                    amountCheckIndex = str(i)
                    break
            else:
                amountTextPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[' + index + ']/android.view.ViewGroup/android.widget.TextView'
                amountText = driver.find_element_by_xpath(amountTextPath).text
                if stockNum in amountText:
                    amountFlag = False
                    amountCheckIndex = str(i + 1)
                    break

        if amountFlag:
            driver.swipe(200, 1760, 200, 1610, 300)
            sleep(1)
    amountCheckPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup[2]/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[' + amountCheckIndex + ']/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup'
    print(amountCheckPath)
    driver.find_element_by_xpath(amountCheckPath).click()
    sleep(1)
    agreePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup[1]'
    driver.find_element_by_xpath(agreePath).click()
    sleep(1)
    confirmPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.TextView'
    driver.find_element_by_xpath(confirmPath).click()
    sleep(1)
    submitUi = 'new UiSelector().textContains("确认认购")'
    driver.find_element_by_android_uiautomator(submitUi).click()
    sleep(1)
    pwd = getPwd('dongCai')['tradePwd']
    print(pwd)
    getKeyCode(driver, pwd)
    sleep(1)
    endUi = 'new UiSelector().text("确认")'
    if isExist(driver, 1, endUi):
        driver.find_element_by_android_uiautomator(endUi).click()
    sleep(3)
    driver.quit()
コード例 #11
0
def buyAErFa(param):
    code = param['code']
    isCash = param['isCash']
    stockNumVal = param['numVal']
    stockNum = param['num']
    isFinancingAll = param['isFinancingAll']
    isCashAll = param['isCashAll']
    settingIndex = param['setIndex']
    settingData = getSetting(settingIndex)
    settingData['appPackage'] = 'com.hkbeiniu.securities'
    settingData['appActivity'] = '.home.activity.UPHKLauncherActivity'
    desired_caps = settingData
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.close_app()
    sleep(3)
    driver.launch_app()
    sleep(5)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("交易")').click()
    sleep(1)
    initApp(driver)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("新股中心")').click()
    sleep(2)
    driver.find_element_by_android_uiautomator(
        'new UiSelector().text("可认购")').click()
    sleep(2)
    codeListPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout'
    codeList = driver.find_elements_by_xpath(codeListPath)
    if len(codeList) < 2:
        codePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.TextView[2]'
        codeText = driver.find_element_by_xpath(codePath).text
        print(codeText)
        if code in codeText:
            buyPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.FrameLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout/android.widget.TextView'
            driver.find_element_by_xpath(buyPath).click()
            sleep(1)
    if not isCash:
        typePath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[6]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView'
        driver.find_element_by_xpath(typePath).click()
        sleep(1)
        financePath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout[2]/android.widget.TextView'
        driver.find_element_by_xpath(financePath).click()
        sleep(1)
        financeRatioPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[7]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView'
        driver.find_element_by_xpath(financeRatioPath).click()
        sleep(1)

        financeRatioFlag = True
        while financeRatioFlag:
            financeRatioListPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout/android.widget.TextView'
            financeRatioList = driver.find_elements_by_xpath(
                financeRatioListPath)
            financeRatioListLen = len(financeRatioList)
            for i in range(financeRatioListLen):
                ratioText = financeRatioList[i].text
                if '90' in ratioText:
                    financeRatioFlag = False
                    ratioEndPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout[5]/android.widget.TextView'
                    driver.find_element_by_xpath(ratioEndPath).click()
                    sleep(1)

            if financeRatioFlag:
                driver.swipe(400, 1500, 400, 1000, 300)
    numPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.TextView'
    numText = driver.find_element_by_xpath(numPath).text
    if stockNum not in numText:
        driver.find_element_by_xpath(numPath).click()
        sleep(1)
        numFlag = True
        while numFlag:
            numListPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout/android.widget.TextView'
            numList = driver.find_elements_by_xpath(numListPath)
            numLen = len(numList)
            for i in range(numLen):
                numText = numList[i].text
                if stockNum in numText:
                    numFlag = False
                    index = str(i + 1)
                    numConfirmPath = '/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout[ ' + index + ']/android.widget.TextView'
                    driver.find_element_by_xpath(numConfirmPath).click()
                    sleep(1)

            if numFlag:
                driver.swipe(400, 660, 400, 550, 300)
    confimPath = '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.RelativeLayout/android.widget.Button'
    driver.find_element_by_xpath(confimPath).click()
    sleep(1)
    pwd = getPwd('youYu')['tradePwd']
    print(pwd)
    getKeyCode(driver, pwd)
    sleep(1)
    driver.quit()