Posts

Load user-defined environment variables in QTP from external XML file

Image
Step 1: Open notepad and copy & paste the following code Database Location SQLServer2012 Username testuser123 Password testpass123 URL https://test123.com Step 2: Save this notepad file as “.XML” format. Step 3: Open a new test in QTP. In test flow section, right click your test and click “settings”. Step 4: In Test Settings pop-up window, click “Environment”, and select Variable type as “User-Defined”. Step 5: Check mark “Load variables and values from external file” checkbox and browse to load the file here. Now our xml file has been loaded successfully in QTP Step 6: How to use these variables now:- username = Environment(“Username”) pass = Environment(“Password”) appurl = Environment(“URL”)

Mouse Click from QTP using DeviceReplay

Sometimes, we often come across a situation where we want QTP to send actual mouse click to some x & y coordinates of screen. QTP in-built “.click” method won’t help you in these situations. So, here is code to perform this action: Set objDeviceReplaytest = CreateObject("mercury.devicereplay") x = objElement.GetROProperty("abs_x") y = objElement.GetROProperty("abs_y") objDeviceReplaytest.MouseClick x + 5 , y + 5,0 Set objDeviceReplaytest = Nothing
Image
Check out SDLC Manger v2.0:  www.sdlcmanager.com A free “no-cost” HP Quality Center like tool, which has been designed to help all freelancers/low-budget testing projects to manage/track their testing activities easily and free. You can manage your requirements, tasks, tests, executions, and defects very easily here. Project User and Project Administrator role’s login credentials have been given to everyone. In addition you can email me if you would need Administrator privileges as well (To manage Domains, Project, Register New User, and Track Audience).

How to search and click a link in a WebTable?

Image
Often, we come across some scenario where we have to search some specific “text” which is link in property, and wants to click it. So, here is the awesome vba function for you to solve the problem 1.  Copy Paste this piece of code in your function library (For example Test.qfl) Function FindTextAndClickLinkInWebTable(ByVal TestObject, ByVal FindText, ByVal FindTextInColumn, ByVal LinkColumn) 'in case of any errors On Error Resume Next 'checking whether the object exist ObjectExist = TestObject.Exist(15) If ObjectExist Then 'setting MatchFound as false MatchFound = FALSE 'finding the total number of rows in the webtable TotalRows = TestObject.RowCount 'looping in the webtable until a match is found For CRow = 1 to TotalRows 'checking whether Searched Text is found searchEEtext = Trim(TestObject.GetCellData(CRow, FindTextInColumn)) ...

How to take screenshot of failed QTP step?

Guys, always take screenshot of the failed steps when creating a QTP test, it will saves your time in identifying the issue thru Result Viewer, and reduce the result analysis time. Below is the simple code to achieve that screenShot = “TestScreenShot”+ ".bmp" Browser("Test").CaptureBitmap screenShot Reporter.ReportEvent micFail, “Failed Reason”, “Failed Reason in Detail”, screenShot

Close any open browsers by VB Script QTP 11

Image
It's always a best practise to close any other open browsers before my actual QTP scripts start. To acheive that, just follow these easy steps 1. Download Windows Sysinternal tools from Microsoft website Link:  https://technet.microsoft.com/en-us/sysinternals/pskill.aspx 2. Store pskill.exe in some folder in C Drive (For Example "C:\TestingProject\Source\QTPTests\VBA\Sysinternal\") 3. Use this code :-) Set objShell = CreateObject("WScript.Shell") pskillLocation = "C:\TestingProject\Source\QTPTests\VBA\Sysinternal\" 'Kill any open IE browser objShell.Run (pskillLocation & "pskill.exe iexplore.exe") wait 2 'Kill any open Firefox browser objShell.Run (pskillLocation & "pskill.exe firefox.exe") wait 2 'Kill any open chrome browser objShell.Run (pskillLocation & "pskill.exe chrome.exe") wait 4

How to maximize FireFox browser from QTP

Unlike Internet Explorer, the QTP in-built maximize function doesn't work for firefox. So, to achieve this goal I did following 1. I added the firefox browser object in the object repository with help of object spy, and renamed it FirefoxBrowser 2. Used this code:- hwnd=Browser("FirefoxBrowser").getROProperty("hwnd") Set FireFox = Description.Create() FireFox("hwnd").value = hwnd Window(FireFox).Maximize