zoukankan      html  css  js  c++  java
  • 关于Python-selenium的文件导入

    2020年9月1号,今天自己写了一个关于文件导入的自动化,整理了资料,简单做以总结。

    关于导入这里,分了两种情况,一个是input标签的,一个是非input标签的。

    首先input标签的这种导入情况可以简单粗暴的直接用send_keys:self.driver.find_element_by_id('id').send_keys('路径')

    再来看一下非input标签,有多个方法,但是我用了这个很有用,就没再尝试其他方法,就把这个记录一下:利用第三方工具AutoIt,链接:链接:https://pan.baidu.com/s/1gxWG5k_n_gnno11SGS443A    提取码:k7vk。或是直接https://www.guru99.com/use-autoit-selenium.html,有安装及使用方法。

    首先把这两个文件一一安装,单击“ SciTE.exe”文件,AutoIT编辑器将打开,然后点击“ Au3Info.exe”文件,元素标识符打开,利用这个“小箭靶”图标进行拖拽到指定位置,找到基本属性信息,然后利用编辑器编写,

    ;ControlFocus("title","text",controlId) Edit1=Edit instance 1
    ControlFocus("open","","Edit1")

    ;Wait 10 seconds for the Upload window to appear
    WinWait("[CLASS:#32770]","","10")

    ;Set the file name text on the Edit field
    ControlSetText("open","","Edit","D: est_modelupingtai.xlsx")
    Sleep(2000)
    ;Click on the Open button
    ControlClick("open","","Button1")

    1. ControlFocus(“ title”,“ text”,controlID)//将输入焦点设置到窗口上的给定控件。
    2. ControlSetText(“标题”,“文本”,controlID,“需要上传的文件路径”)//设置控件的文本。
    3. ControlClick(“ title”,“ text”,controlID)//将鼠标单击命令发送到给定控件。

    编写完成后无法直接执行此脚本,需要编译此脚本。

    对于编译此脚本,有两个选项“ compile script x64 ”和“ compile script x86 ”,如果使用的是Windows 32位计算机,则选择“ compile script x86”;对于Windows 64位计算机,则选择编译脚本x64。”

    然后selenium编辑器里运行。

    好了,写到这里该记录的记录完了。如果有需要的朋友可以自己查看我发的第二条链接,那里记录的很完整。

  • 相关阅读:
    Sum Root to Leaf Numbers 解答
    459. Repeated Substring Pattern
    71. Simplify Path
    89. Gray Code
    73. Set Matrix Zeroes
    297. Serialize and Deserialize Binary Tree
    449. Serialize and Deserialize BST
    451. Sort Characters By Frequency
    165. Compare Version Numbers
    447. Number of Boomerangs
  • 原文地址:https://www.cnblogs.com/lycun-0426/p/13596845.html
Copyright © 2011-2022 走看看