RF-AutoIT:无法在Chrome中上传文件

时间:2018-02-09 12:57:12

标签: robotframework autoit

我正在尝试使用以下代码为3个基于浏览器的文件上传创建一个公共exe。

  • IE(选择要上传的文件),
  • Chrome(开放),
  • Firefox(文件上传)

这适用于IE,但不适用于Chrome和FireFox。没有错误但它没有显示给定文件和路径。

我将在我的Robot Framework脚本中使用此.exe。

#include <MsgBoxConstants.au3>

SelectWindowBasedOnTitle()

Func SelectWindowBasedOnTitle()

    $winList = WinList()
    $wTitle = CheckWindows($winList)

   IF $wTitle == "Choose File to Upload" Then
            IE()
   ElseIf $wTitle == "Open" Then
            Chrome()
   Else
            FireFox()
   EndIf
EndFunc


Func CheckWindows($aArray)

    For $i = 1 To Ubound($aArray) - 1
        If WinActive($aArray[$i][1]) Then $wTitle= $aArray[$i][0] ;MsgBox(0, "Window Check", $aArray[$i][0] & " is active.")
    Next
    Return $wTitle
EndFunc


Func Example()
    $wText = WinGetText("[ACTIVE]")
EndFunc

Func IE()
    ControlFocus("Choose File to Upload","","Edit1")
    ControlSetText("Choose File to Upload","","Edit1",$CmdLine[1])
    ControlClick("Choose File to Upload","","Button1")
EndFunc

Func Chrome()
    ControlFocus("Open","","Edit1")
    ControlSetText("Open","","Edit1",$CmdLine[1])
    ControlClick("Open","","Button1")
EndFunc

Func FireFox()
    ControlFocus("File Upload","","Edit1")
    ControlSetText("File Upload","","Edit1",$CmdLine[1])
    ControlClick("File Upload","","Button1")
EndFunc

这种方式我在我的机器人脚本中使用。你能帮我理解有没有办法实现自动化

${FileInfo}     ${CURDIR}\\Xpaths.txt
    ${AutoIT}     ${CURDIR}\\BrowserBasedWindowSelection.exe
    Run Process   ${AutoIT}   ${FileInfo}

0 个答案:

没有答案