Jump to content

Cant upload files in Chrome


bbk4163
 Share

Recommended Posts

I am trying to crate a common exe for IE(Choose File to Upload),Chrome(Open),Firefox (File Upload) browser based file upload using below code. This is working for for IE but not for Chrome and FireFox not sure what is the issue? 

I will be using this .exe in my Robot Framework script. 

   

#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

This way i am using in my Robot script. Could you please help me understand is there a way to automate in Chrome and Firefox. 
   

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...