appium自动化上传抖音视频

from appium import webdriver
import time
# 模拟滑屏
from appium.webdriver.common.touch_action import TouchAction


def start_driver():
    desired_caps = {}
    # 不重置apk
    desired_caps['noReset'] = True
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '8.0'
    desired_caps['deviceName'] = 'OnePlus 3T'
    desired_caps['appPackage'] = 'com.ss.android.ugc.aweme'
    desired_caps['appActivity'] = 'com.ss.android.ugc.aweme.main.MainActivity'
    # 启动
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.implicitly_wait(2)

    print('已成功连接设备')
    upload_video(driver)


def upload_video(driver):
    '''
    发布视频
    :param driver:
    :return:
    '''
    try:
        while True:
            driver.tap([(432, 1935), (648, 2076)], 500)  # +号
            time.sleep(1)
            if driver.find_element_by_id('com.ss.android.ugc.aweme:id/wn'):
                break
            else:
                print('没找到')

        driver.tap([(837, 1902), (933, 1998)], 500)  # 上传
        time.sleep(1)
        driver.tap([(0, 351), (267, 617)], 500)  # 视频1
        time.sleep(1)
        driver.tap([(0, 351), (267, 617)], 500)
        driver.find_element_by_id('com.ss.android.ugc.aweme:id/mt').click()  # 下一步
        driver.find_element_by_id('com.ss.android.ugc.aweme:id/s3').click()  # 下一步
        driver.find_element_by_id('com.ss.android.ugc.aweme:id/apk').send_keys('bilibili')
        driver.find_element_by_id('com.ss.android.ugc.aweme:id/apw').click()  # 发布
        time.sleep(2)
    except Exception as err:
        print(err)


if __name__ == '__main__':
    start_driver()

 

你可能感兴趣的:(appium抖音,appium)