Friday, October 25, 2013

Auto Multi Upload using C#, Selenium, and AUTOIT.

Files to upload ( with different path ):

"C:\40vid\Curse of Chucky\Curse of Chucky.mp4"
"C:\40vid\Restrepo\Restrepo.mp4" 


Using this method will not working, using Process.Start

'"C:\40vid\Curse of Chucky\Curse of Chucky.mp4" "C:\40vid\Restrepo\Restrepo.mp4"'
and this
""C:\40vid\Curse of Chucky\Curse of Chucky.mp4" "C:\40vid\Restrepo\Restrepo.mp4""

To work on windows ( using xp sp3 ) from commandline using Process.Start, space must inside double quote

like this:
" 'C:\40vid\Curse of Chucky\Curse of Chucky.mp4' 'C:\40vid\Restrepo\Restrepo.mp4' "
But if we use path like that, will not working on Upload windows.

Solutions

In C#

string gb1 = @"C:\40vid\Curse of Chucky\Curse of Chucky.mp4";
string gb2 = @"C:\40vid\Restrepo\Restrepo.mp4";
string jadikansatu = @"""" + "'" + gb1 + "'" + " " + "'" + gb2 + "'" + @"""";
 
 

 
In AutoIt v3
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=D:\Bara\selenium&autoit\youtubeauto.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
WinWait ("File Upload");
WinActivate("File Upload");
;Local $file = '"C:\40vid\Curse of Chucky\Curse of Chucky.mp4" "C:\40vid\Restrepo\Restrepo.mp4"';
;ControlSetText("File Upload", "", "[CLASS:Edit; INSTANCE:1]", ''&$file&'' )

$removedoublequotes = StringReplace($CmdLine[1], '"', '')
$gantisinglequotes2double = StringReplace($removedoublequotes, "'", '"')
ControlSetText("File Upload", "", "[CLASS:Edit; INSTANCE:1]", $gantisinglequotes2double)
ControlClick("File Upload", "", "[CLASS:Button; INSTANCE:2]")
;ControlClick("File Upload", "", "[CLASS:Button; INSTANCE:2]")



and compile to auto.exe

add this before clicking browse button and done
Process.Start(@"C:\auto.exe", jadikansatu);
Problem solve