1. <i id='ep75Z'><tr id='ep75Z'><dt id='ep75Z'><q id='ep75Z'><span id='ep75Z'><b id='ep75Z'><form id='ep75Z'><ins id='ep75Z'></ins><ul id='ep75Z'></ul><sub id='ep75Z'></sub></form><legend id='ep75Z'></legend><bdo id='ep75Z'><pre id='ep75Z'><center id='ep75Z'></center></pre></bdo></b><th id='ep75Z'></th></span></q></dt></tr></i><div id='ep75Z'><tfoot id='ep75Z'></tfoot><dl id='ep75Z'><fieldset id='ep75Z'></fieldset></dl></div>

      <legend id='ep75Z'><style id='ep75Z'><dir id='ep75Z'><q id='ep75Z'></q></dir></style></legend>
    2. <small id='ep75Z'></small><noframes id='ep75Z'>

      • <bdo id='ep75Z'></bdo><ul id='ep75Z'></ul>
      <tfoot id='ep75Z'></tfoot>

      使用python自动从windows文件对话框打开文件

      时间:2023-09-12

      <small id='EaaPp'></small><noframes id='EaaPp'>

    3. <legend id='EaaPp'><style id='EaaPp'><dir id='EaaPp'><q id='EaaPp'></q></dir></style></legend>

            <tbody id='EaaPp'></tbody>
          <i id='EaaPp'><tr id='EaaPp'><dt id='EaaPp'><q id='EaaPp'><span id='EaaPp'><b id='EaaPp'><form id='EaaPp'><ins id='EaaPp'></ins><ul id='EaaPp'></ul><sub id='EaaPp'></sub></form><legend id='EaaPp'></legend><bdo id='EaaPp'><pre id='EaaPp'><center id='EaaPp'></center></pre></bdo></b><th id='EaaPp'></th></span></q></dt></tr></i><div id='EaaPp'><tfoot id='EaaPp'></tfoot><dl id='EaaPp'><fieldset id='EaaPp'></fieldset></dl></div>

          • <bdo id='EaaPp'></bdo><ul id='EaaPp'></ul>
            • <tfoot id='EaaPp'></tfoot>
              1. 本文介绍了使用python自动从windows文件对话框打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我进行自动化测试并获得一个文件对话框.我想用 python 或 selenium 从 windows 打开文件对话框中选择一个文件.

                注意:该对话框由其他程序提供.我不想用 Tkinter 创建它.

                窗口看起来像:

                .

                如何做到这一点?

                解决方案

                考虑使用

                代码示例,在记事本中打开文件.请注意,语法取决于区域设置(它使用 GUI 程序中可见的窗口标题/控件标签):

                来自 pywinauto 导入应用程序app = application.Application().start_('notepad.exe')app.Notepad.MenuSelect('文件->打开')# app.[窗口标题].[控件名称]...app.Open.Edit.SetText('filename.txt')app.Open.Open.Click()

                I do automated testing and get a file dialog. I want to choose a file from the windows open file dialog with python or selenium.

                NOTE: The dialog is given by an other program. I don't want to create it with Tkinter.

                The Window looks like:

                .

                How to do this?

                解决方案

                Consider using the pywinauto package. It has a very natural syntax to automate any GUI programs.

                Code example, opening a file in notepad. Note that the syntax is locale dependent (it uses the visible window titles / control labels in your GUI program):

                from pywinauto import application
                app = application.Application().start_('notepad.exe')
                app.Notepad.MenuSelect('File->Open')
                # app.[window title].[control name]...
                app.Open.Edit.SetText('filename.txt')
                app.Open.Open.Click()
                

                这篇关于使用python自动从windows文件对话框打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Selenium:Runtime.executionContextCreated 具有无效的“上下 下一篇:带有基于文件的电子邮件后端服务器的 Django 测试

                相关文章

                最新文章

              2. <small id='seXV6'></small><noframes id='seXV6'>

                <legend id='seXV6'><style id='seXV6'><dir id='seXV6'><q id='seXV6'></q></dir></style></legend>

                1. <tfoot id='seXV6'></tfoot>

                  <i id='seXV6'><tr id='seXV6'><dt id='seXV6'><q id='seXV6'><span id='seXV6'><b id='seXV6'><form id='seXV6'><ins id='seXV6'></ins><ul id='seXV6'></ul><sub id='seXV6'></sub></form><legend id='seXV6'></legend><bdo id='seXV6'><pre id='seXV6'><center id='seXV6'></center></pre></bdo></b><th id='seXV6'></th></span></q></dt></tr></i><div id='seXV6'><tfoot id='seXV6'></tfoot><dl id='seXV6'><fieldset id='seXV6'></fieldset></dl></div>

                  • <bdo id='seXV6'></bdo><ul id='seXV6'></ul>