Wednesday, February 6, 2013

Handle Download Bar in IE9

Below code helpful whenever do you want to download and save from any web application which is opened in IE9

Set DeviceReplay = CreateObject("Mercury.DeviceReplay") Browser("creationtime:=0").WinObject("nativeclass:=DirectUIHWND","regexpwndclass:=DirectUIHWND", "index:=0").highlight
 ' Right-click on Save button drop down down arrow in Download Bar
 Browser("creationtime:=0").WinObject("nativeclass:=DirectUIHWND","regexpwndclass:=DirectUIHWND", "index:=0").Clickontext "Save",,,,,true,micRightBtn,true

 'Save drop down list get focus by pressing 'down arrow'

 DeviceReplay.PressKey 208 ' 'down arrow' key Presses
   'Press the 'a' key to activate the drop-down button and then activate the Save As command. DeviceReplay.PressKey 30 ' 'a' key Presses
   Set DeviceReplay = Nothing
 'Enter the File path

 Browser("creationTime:=0").Dialog("Save As").WinEdit("Edit").Set "C:\Exportfile.xls"
 ' click on Save button
 Browser("creationTime:=0").Dialog("Save As").WinButton("Save").Click

See the more details in below HP support website

Unified-Functional-Testing/QTP-11-can-t-recognize-the-download-bar-of-IE9