TESTEVERYTHING

Thursday, 28 April 2011

Highlight the text on page using the QTP


Hi All,
Someone asked me how to highlight the text on page using the QTP. So here I have created a function that will find the text on page and highlight it if finds else not.


REM  ——  Set page object     ———
set objpage = Browser("BrowserName").Page("Pagename")


call   HighLightTextPresentOnPage(objpage ,"News" )

Function HighLightTextPresentOnPage(byval objpage , byval Textvalue )

On error resume next

REM ——- Create child object description
Set childobj = Description.Create()
childobj("micclass").value="WebElement"
childobj("html tag").value=".*[A-Za-z0-9].*"
childobj("outertext").value =Textvalue

REM  ———-Create ALL child object 
set allobj = objpage.ChildObjects(childobj)

 REM here highlight method we will use that is in build in QTP for object
For i=1 to allobj.count-1
    allobj.Item(i).HighLight
Next
           If allobj.count > 0 then
              HighLightTextPresentOnPage = true
           Else
              HighLightTextPresentOnPage = false
           End if

             On Error GoTo 0
End Function

Monday, 18 April 2011

Close All Browser QTP

‘ This function Close All open Browser

REM *************************************************************************
REM this function close All open browser
Public Function   fn_CloseAllBrowser()

    While Browser(“CreationTime:=0″).Exist

          Browser(“CreationTime:=0″).Close

   Wend

End Function

REM *************************************************************************
Rem another way to close browser here  this function terminate application ‘process
rem like internet explorer exe will close from system process
dim sApplicationExe
sApplicationExe = “iexplore.exe”
Rem call function to close application process
call fn_CloseApplication( sApplicationExe)
REM This function kill the given process exe  through task manager
Public Function  fn_CloseApplication( byval sApplicationExe)

   Dim strComputer

   Dim objWMIService

   Dim colProcesses

  Dim objProcess

  strComputer = “.”

  Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2″)
  Set colProcesses = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘”&sApplicationExe&”‘”)

  For Each objProcess in colProcesses

   objProcess.Terminate()

  Next

  Set objWMIService = Nothing

  Set colProcesses=Nothing

End Function

REM through this function you can close any application process



QTP is not recording the web application

Hi All,
I faced the problem when I installed the QTP in vista.QTP  was not recording any web application then i tried to check with OBJECT SPY how its identify the web object Object Spy identify the each web object as a winobject. Then i found the solution to solve this problem this was because vista User control . In Vista you need to off USER CONTROL option after that QTP works fine and records the web application. To off the USER CONTROL option follow the following steps:
Click Start  >Control Panel>User Accounts and Family Safety>User Accounts
and uncheck  the Turn User Account Control On or OFF option

QTP not recording web application in VISTA

Here is the sequence of tries
1. Try Opening QTP-11 as Administrator mode
Right click QTP short cut>>Run As Administrator Mode
2. If above does not work then go to control panel and set User account setting to low level ie. not to notify and then repeat step-1
3. If both 1&2 does not work then go to IE>Tools>Internet Options>Advanced>Browsing>Enable Third Party Browser extension ( usually in IE8 by default it will be enabled) and then repeat step-1/2
4. If all above 3- does not work then you may think of running IE as 32-bit ( but i din;t understood how one can run IE8 32-bit browser on 64-bit machine. ( I have not tried this solution…/ And i suggest not to try step-4.)

Translate







Tweet