ramasai Posted April 9, 2013 Share Posted April 9, 2013 Hi All ,I'm new to this forum and to AutoIT as well. I'm basically testing a web application through selenium RC , using Eclipse and Java for this purpose.I'm using AutoIt script to download and save a excel file . This script takes 2 params, title and operation, but on using this recently some of my files get corrupted and not able to open.I'm confidently able to say that when file comes out of AutoIT it is corrupt because, I debugged till the point of just opening the 'File Download' Dialog and then saved a file manually and was able to see that the file was downloaded correctly, but trying the same with AutoIt the file was corrupted.1) Can anyone please tell me if this ia a common issue.2) Thinking that this problem araised because I open and close AutoIt for every testcase, this could abruptly stop the thread or so....I tried to tweak the code so that AutoIT is started at the satrt of the script and as and when it spots a File Download it has to immediately download the file and also iterating it for every 2 secs, but I was not able to do it.I used AdlibRegister to do this.Unable to post my code within the Code layout. Pasting belowAutoItSetOption("WinTitleMatchMode","2") ; set the select mode to select using substringWhile 1If $CmdLine[0] < 2 then ; Arguments are not enough msgbox(0,"Error","Supply all the arguments, Dialog title,Run/Save/Cancel and Path to save(optional)") Exit Else AdlibRegister("SaveDialog",2000)EndIfWEndFunc SaveDialog; wait Until dialog box appearsWinWaitActive($CmdLine[1]) ; match the window with substring$title = WinGetTitle($CmdLine[1]) ; retrives whole window titleWinActivate($title)If (StringCompare($CmdLine[2],"Open",0) = 0) ThenWinActivate($title)ControlClick($title,"","Button1")EndIfIf (StringCompare($CmdLine[2],"Save",0) = 0) ThenWinWaitActive($title)ControlClick($title,"","Button2"); Wait for the new dialogbox to openSleep(2)WinWait("Save As")$title = WinGetTitle("Save As");$title = WinGetTitle("[active]")If($CmdLine[0] = 2) Then;click on the save buttonSleep(1000)WinWaitActive($title);ControlSetText($title,"","ToolbarWindow323","Address: Desktop")ControlSend("$title","","ToolbarWindow323","Address: Desktop")Sleep(1000)Send("{Enter}")ControlClick($title,"&Save","Button1")$title = WinGetTitle("Export Data - Windows Internet Explorer")sleep(2)WinWaitActive($title)sleep(2)WinClose("Export Data - Windows Internet Explorer","");Else;Set path and save fileWinWaitActive($title)ControlSetText($title,"","Edit1",$CmdLine[3])ControlClick($title,"&Save","Button1")$title = WinGetTitle("Export Data - Windows Internet Explorer")sleep(2)WinWaitActive($title)sleep(2)WinClose("Export Data - Windows Internet Explorer","");EndIfEndIfIf (StringCompare($CmdLine[2],"Cancel",0) = 0) ThenWinWaitActive($title)ControlClick($title,"","Button3")EndIfEndFuncPlease suggest if there are any mistakes in my code and how I should make it work the way I want it to...Thanks in advance Link to comment Share on other sites More sharing options...
guinness Posted April 9, 2013 Share Posted April 9, 2013 Why complicate matters when you can use InetGet? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
ramasai Posted April 9, 2013 Author Share Posted April 9, 2013 Thanks Alot for the reply but, InetGet as I see is actually for downloading the file directly and file is already existing in the web page. Here the file is getting generated newly (after report has things fetched from the db). I Actually click on a button that generates the file and then the File Download dialog appears, from which i can download. Please let me know if there's another way to do this. Thanks again. Link to comment Share on other sites More sharing options...
guinness Posted April 9, 2013 Share Posted April 9, 2013 (edited) What is the website exactly? Edit: Added question mark! Edited April 9, 2013 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
kylomas Posted April 9, 2013 Share Posted April 9, 2013 ramasai, You are using adlib incorrectly because: - your registering it in a tight loop so it cannot finish an iteration before the timer is reset - even if you fix the tight loop the adlib is not likely to finish within the iteration specified because of sleep's and dialog waits As to the file corruption, I'm going to guess that you have multiple operations to the same file (because of the adlib problem above) and given the right sequence will corrupt the file. A better technique would be: - run loop to detect that the file needs to be generated - do whatever you do to generate it - wait till your file is generated then continue your detection loop When you answer guiness's question you may get better/clearer advice. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now