uiautomation-new 控件方位的使用

下载亚马逊分类账

复制代码
import time
import uiautomation as auto


def handle_date(window, start_time='08/01/2026', end_time='08/31/2026'):
    """
    日期范围
    :param start_time: 开始日期
    :param end_time: 结束日期
    :return:
    """
    # 开始日期
    from_edit = window.EditControl(Name='开始日期')
    from_edit.Click()
    time.sleep(1)
    from_edit.Press_Hotkey("ctrl", "a")
    from_edit.Press_Hotkey("backspace")
    time.sleep(1.5)
    auto.SetClipboardText(start_time)
    from_edit.Press_Hotkey('ctrl', 'v')
    time.sleep(0.5)
    from_edit.Press_Hotkey("enter")

    # 结束日期
    to_edit = window.EditControl(Name='结束日期')
    time.sleep(1)
    to_edit.Press_Hotkey("ctrl", "a")
    to_edit.Press_Hotkey("backspace")
    time.sleep(1.5)
    auto.SetClipboardText(end_time)
    to_edit.Press_Hotkey('ctrl', 'v')
    time.sleep(0.5)
    to_edit.Press_Hotkey("enter")

    daterange = window.TextControl(Name='日期范围')
    if daterange.Exists(1):
        daterange.Click()

    eventdate = window.TextControl(Name='事件日期')
    if eventdate.Exists(1):
        eventdate.Click()


def inventory_classification():
    """
    库存分类
    访问链接: https://sellercentral.amazon.com/reportcentral/LEDGER_REPORT/1
    流程: 一览视图->事件类型-任何状况 -> 日期范围-确切日期->设置日期范围->请求下载.csv文件
    :return:
    """
    window = auto.PaneControl(ClassName='Chrome_WidgetWin_1', RegexName='.*Chromium')
    # Name	一览视图
    overview = window.RadioButtonControl(Name='一览视图')
    if not overview.GetSelectionItemPattern().IsSelected:
        overview.Click()

    # Name	亚马逊运营中心
    amazon_center = window.RadioButtonControl(Name='亚马逊运营中心')
    if not amazon_center.GetSelectionItemPattern().IsSelected:
        amazon_center.Click()

    # Name	请求下载 .csv 文件  滚动页面展示
    down_file = window.ButtonControl(Name='请求下载 .csv 文件')
    down_file.ScrollIntoView()

    # Name	按时间段汇总报告
    # 先定位按时间段汇总报告文本控件,根据文本控件再定位其下方的下拉框控件
    summarize_report = window.TextControl(Name='按时间段汇总报告')
    summarize_report_combox = auto.GroupControl().Below(summarize_report)
    summarize_report_combox.Click()
    list_item = window.ListItemControl(Name='每月')
    if list_item.Exists(1):
        list_item.Click()
    time.sleep(1)


    # Name	日期范围
    daterange = window.TextControl(Name='日期范围')
    daterange_combox = auto.GroupControl().Below(daterange)
    daterange_combox.Click()
    list_item1 = window.ListItemControl(Name='具体月份')
    if list_item1.Exists(1):
        list_item1.Click()
    time.sleep(1)

    handle_date(window)
相关推荐
程序员Query4 小时前
day01-认识Go语言 + golang环境的安装
开发语言·后端·golang
§ꦿCFོ༉13 小时前
嵌入式八股文—C语言入门学习(四)
c语言·开发语言·学习
投图匠14 小时前
十种不同风格的 CTP接口 框架
开发语言·python
2601_9679801115 小时前
深入理解词向量算法及其在Python中的实践
python·word2vec·glove·fasttext·词向量
129Lab16 小时前
电池循环测试数据自动化分析:用Python+AI工具构建一键式寿命评估流水线
python·数据分析·电池测试·数据自动化·寿命评估
treasure14016 小时前
【复古】浅尝Django前后端不分离
前端·css·python·django·bootstrap·html·web
Dmz丶17 小时前
前端转 AI 100 天 Day 44:前端集成实战——用 React 给 Agent 做个正式界面
python
jay神17 小时前
基于 YOLOv8 的手势识别系统(Web 版)
前端·人工智能·python·深度学习·yolo·计算机视觉·计算机毕业设计
DeepVisionary17 小时前
阿里云上线旗舰多模态新模型,不公布跑分且限时14天退役
python·自动化
东莞市云毅网络有限公司17 小时前
FAQ 覆盖度打分:TF-IDF 与向量嵌入双路召回的 Python 实现
python·数据清洗·rag·企业知识库·文档解析