Thursday, December 31, 2009

Browser Control in QTP using DOT Net Factory

Create browser control instance in QTP using DOT Net factory, then you are able to browse any web pages without browsers. Execute the below code,


Set obj = DotNetFactory.CreateInstance("System.Windows.Forms.Form","System.Windows.Forms")
Set objBrwsr = DotNetFactory.CreateInstance("System.Windows.Forms.WebBrowser","System.Windows.Forms")

With objBrwsr
.Width=800
.Height=800
.AllowNavigation=True
.AllowWebBrowserDrop=True
.IsWebBrowserContextMenuEnabled=True
End With

With obj .Controls.Add objBrwsrEnd with
objBrwsr.Navigate("
www.google.com")
obj.showdialog

Set obj =Nothing
Set objBrwsr=Nothing


You will get DOT Net Dialog with browser control as same as below,



Thanks and regards,

Asiq Ahamed

2 comments:

  1. Hi Asiq

    Well Done!!

    Thanks
    Karthi

    ReplyDelete
  2. Hi asiq thanks....
    Great Work buddy...
    Keep it up....

    ReplyDelete