Sunday, 12 November 2017

Vbscript: Print the Pattern

Expected Pattern:
*
**
***


Code:

str=""
For r = 0 To 2 Step 1
   
   
    For c=0 to 2 Step 1
   
   
     If c<=r Then
        
         str=str+"*"
        
     End If
       
    Next
   
    str=str+vbnewline
Next

print str

Friday, 10 November 2017

UFT Interview Question: Alternate lowercase and uppercase letter in word: Capegemini==>CaPeGeMiNi

str="Capegemini"

strfinaltext=""
 
For i = 1 To len(str) Step 1
    If i mod 2 <>0 Then
        strfinaltext=strfinaltext+ ucase(mid(str,i,1))
       
    Else
   
        strfinaltext=strfinaltext+lcase(mid(str,i,1))
    End If
Next

msgbox strfinaltext  'CaPeGeMiNi

Vbscript Typename to get type of object

Set Otable=Browser("Sample Page All Page").Page("Sample Page All Page").WebTable("EmpiId")
Set olink=otable.ChildItem(2,7,"link",0)
msgbox typename(olink) 'textlink'

set objdlgbutton=Browser("Sample Page All Page_2").Dialog("Message from webpage").WinButton("OK")
msgbox typename(objdlgbutton) 'stdbutton

set webbtn=Browser("Sample Page All Page_2").Page("Sample Page All Page").WebButton("Submit")
msgbox typename(webbtn) 'htmlbutton

Set oradio=otable.ChildItem(2,7,"link",0)
msgbox typename(oradio) 'textlink'

set oweblist=Browser("Sample Page All Page_2").Page("Sample Page All Page").WebList("Country")
msgbox typename(oweblist) 'htmllist'


set objradio=Browser("Sample Page All Page_2").Page("Sample Page All Page").WebRadioGroup("gender")
msgbox typename(objradio) 'htmradiogroup'


set owebedit=Browser("Sample Page All Page_2").Page("Sample Page All Page").WebEdit("browser")
msgbox typename(owebedit) 'htmledit'

Sunday, 5 November 2017

QTP Interview Questions:

Listing All the questions I faced in interviews so far:

UFT:

1)Explain Framework used in your project
2) Explain your roles and responsibilities
2)How do you do Error Handling
3) How many cases are there in your test suite
4)How do you do reporting
5) Open test from present in ALM using AOM
6)If hierarchy if object present in OR changes and its affecting 50 scripts, how would you deal with it
7) If I give yo something to automate how would you automate. What will be the steps.
8)what is virtual Objects
9)What is Visual Relation Identification works
10) How object Identification works






VBSCRIPT: Questions:

1)How to covert number to string ( 123 should be shown as One Two Three)
2) Explain On Error Resume Next
3) If function had 3 arguments and I want to pass 4th argument how would you deal with it
4) Count occurrence of each character in a string
5) How to handle xml files. If I want to get particular node value in xml file how can I get it.
6) Can function return multiple values
7) If I want to return multiple values from subroutine how can i do it
8) Separate xls,txt,csv files from folder
9)


Vbscript: Instr() or Regular Expression

 sString = “Welcome User, You have 5 New Mails”
 sSubString = “Welcome .*, You have .* New Mails”‘Check if the string pattern matches – using 

RegExp object
Set objRE = New RegExp
objRE.Global = True
objRE.Pattern = sSubString
msgbox objRE.Execute(sString).Count ‘ — msgbox returns the value 1 as the RegExp object returns 1 match 

‘Check if the string pattern matches  – using InStr
msgbox InStr(1, sString, sSubString, 1)  ‘ — msgbox returns the value 0  as it is not able to find the match using InStr

Thursday, 2 November 2017

Using ReadyState in UFT

The readyState property in QTP returns the loading status of the current browser . This property Will be of immense help if the AUT under test has a lot of sync issues while running the script .

This property returns one of four values :
1. uninitialized(1) Has not started loading yet.
2. loading(2) Is loading
3.Interactive(3) Has loaded enough and the user can interact with it
4.complete(4) Fully loaded

close the browser once the page is loaded completely.

    If Browser (Google).object.ReadyState=4 Then
     Browser(Google).Close
    End If

Wednesday, 1 November 2017

System lock during QTP Automation Test Script Execution

system lock during QTP Automation Test Script Execution

There are few ways to prevent windows to lock the system:
Way1:
Download the software Caffeine 1.4 and install on the machine where u run the scripts.
Way 2:
Create a .vbs file (with the below mentioned code) and a task in task scheduler
Const DELAY_MINUTES = 10
Wscript.Sleep DELAY_MINUTES * 60000
Do
CreateObject(“Wscript.Shell”).SendKeys “+”
Wscript.Sleep DELAY_MINUTES * 60000
Loop
Way 3:
Create a .vbs file (with the below mentioned code) and a task in task scheduler
Const micVoid = 0
Const micByte = 26
Const micLong = 3
Const KEYEVENTF_KEYUP = &H2
Set Extern = CreateObject("Mercury.ExternObj")
extern.Declare micVoid, "keybd_event", "user32", "keybd_event", micByte, micbyte, miclong, micLong
Extern.Declare micVoid, "Sleep", "kernel32", "Sleep", micLong
While True
extern.keybd_event 0, 0, KEYEVENTF_KEYDOWN, 0
Extern.Sleep 20000
Wend
-********************-*****************-*****************************-*********************************-*****************************
We can even run the scripts when the system is locked, but QTP may not replay constantly on a locked machine
The Quick Test Professional computer is locked or logged off.
Quick Test Professional was launched without permission to interact with the desktop.
The following registry key which enables you to run tests on a remote computer, even on an incompatible execution environment:
HKEY_CURRENT_USERSoftwareMercury InteractiveQuick Test ProfessionalMicTestSkipEnvironmentChecks
Set the registry key to 1 to prevent the remote execution checks, and 0 to perform the checks.

pic

 qt...