#-*- coding:utf-8 -*-
from appium import webdriver
from selenium.webdriver.common.by import By
from appium.webdriver.extensions.android.nativekey import AndroidKey
import time
from datetime import datetime
import time
from datetime import timedelta
import csv
from selenium.common.exceptions import NoSuchElementException
from appium.webdriver.common.touch_action import TouchAction
import pandas as pd
from bs4 import BeautifulSoup
import requests
import re
import numpy as np
import backtrader as bt
desired_caps = {
'platformName': 'Android', # 被测手机是安卓
'platformVersion': '10', # 手机安卓版本
'deviceName': 'xxx', # 设备名,安卓手机可以随意填写
'appPackage': 'com.eg.android.AlipayGphone', # 启动APP Package名称
'appActivity': '.AlipayLogin', # 启动Activity名称
'unicodeKeyboard': True, # 使用自带输入法,输入中文时填True
'resetKeyboard': True, # 执行完程序恢复原来输入法
'noReset': True, # 不要重置App
'newCommandTimeout': 6000,
'automationName' : 'UiAutomator2',
'skipServerInstallation':True
# 'app': r'd:\apk\bili.apk',
}
# 连接Appium Server,初始化自动化环境
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# 设置缺省等待时间
driver.implicitly_wait(10)
def data():
#下拉列表
driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[6]/android.view.View').click()
time.sleep(2)
#基金编码
ele0=driver.find_element(By.XPATH,'//android.webkit.WebView/android.view.View/android.view.View/android.view.View[2]')
#持仓金额
ele1=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[2]/android.view.View[1]')
ele2=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[2]/android.view.View[2]')
#持有收益
ele7=driver.find_element(By.XPATH,'//android.view.View/android.view.View[5]/android.view.View[4]/android.view.View[1]')
ele8=driver.find_element(By.XPATH,'//android.view.View/android.view.View[5]/android.view.View[4]/android.view.View[2]/android.view.View')
#持仓成本价
ele3=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[4]/android.view.View[1]')
ele4=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[4]/android.view.View[2]')
#持仓份额
ele5=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[5]/android.view.View[1]')
ele6=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[5]/android.view.View[2]')
#基金净值
ele9=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[7]/android.view.View[1]')
ele10=driver.find_element(By.XPATH,'//android.view.View[5]/android.view.View[7]/android.view.View[7]/android.view.View[2]')
rate = float(ele2.text.replace(',','')) / 10000
print("基金代码:%s"%ele0.text,"持仓金额:%s"%ele2.text,"目标市值10000,当前仓位占比:%.2f"%rat
Alipay appium
最新推荐文章于 2024-05-18 21:09:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)