Wednesday, 31 January 2018

Html Report In Process

Public objfso
Dim ResultFolder:ResultFolder="C:\Users\config\Desktop\UFT\"
Set objfso=Createobject("Scripting.FileSystemObject")


If NOT objfso.FolderExists(ResultFolder) then
   
    Msgbox "Folder Does Not Exist. Proceeding with creation"
    objfso.CreateFolder(ResultFolder)
   
 End If

 Filename=ResultFolder&Environment.Value("TestName")&".html"
 Print Filename
 Set Logfile=objfso.CreateTextFile(ResultFolder&Environment.Value("TestName")&".html")
 Logfile.Close()



 Call InitiateLog()
 Call WriteLog("PASS","teststep","stepdesc")

 Call WriteLog("Fail","teststep2","stepdesc2")
 Call Completelog()


 Function InitiateLog()

 Set ofile=objfso.OpenTextFile(Filename,8)

 ofile.WriteLine("<table border=1 cellspacing=1 > <tr>")
 ofile.WriteLine("<th>Status</th>")
 ofile.WriteLine("<th>Stepname</th>")
 ofile.WriteLine("<th>stepDescription</th>")

 'link=<a href='"https://www.w3schools.com">Visit W3Schools.com!</a>
' ofile.WriteLine("<td>&link</td>")
 ofile.WriteLine ("</tr>")

 ofile.Close

 End Function
 




 Function WriteLog(strStatus,Stepname,stepDescription)

 Set ofile=objfso.OpenTextFile(Filename,8)

 ofile.WriteLine("<tr>")
 ofile.WriteLine("<td>"&strStatus&"</td>")
 ofile.WriteLine("<td>"&Stepname&"</td>")
 ofile.WriteLine("<td>"&stepDescription&"</td>")

 'link=<a href='"https://www.w3schools.com">Visit W3Schools.com!</a>
' ofile.WriteLine("<td>&link</td>")
 ofile.WriteLine ("</tr>")
 ofile.Close


 End Function


 Function Completelog()
 Set ofile=objfso.OpenTextFile(Filename,8)
 ofile.WriteLine("</table>")
 ofile.Close

 End Function
  

Sunday, 21 January 2018

VbScript Classes

How to create class and constructor using VBScript

Class sampleClass
Private str


REM Methods declared as private wont be shown after Class Object
Private sub Class_Initialize()
msgbox("I am constructor")
End Sub

REM Methods declared as private wont be shown after Class Object
Private sub Class_Terminate()
msgbox("I am destructor")
End Sub




REM Methods declared as Public are shown after Class Object
Public function setString(strVar)
str=strVar
End Function




REM Methods declared as Public are shown after Class Object
Public function getString()
getString=str
End Function
End Class

Set strObj= New sampleClass
strObj.setString("day")
temp=strObj.getString
msgbox(temp)

How to check a browser window is minimized

How to check a browser window is minimized

Extern.Declare micLong, "GetMainWindow", "user32" ,"GetAncestor",micLong, micLong 'This is the declaration for the referencing "GetMainWindow" with the GetAncestor method in user32.dll.
GA_ROOT=2

Just opened Gmail and checked whether the browser is minimized or maximized.

We cannot directly use Browser().GetROProperty("minimized") here.


Set oBrowser=description.Create
oBrowser("micclass").value="Browser"
oBrowser("name").value="Gmail.*"

hwnd=Browser(oBrowser).GetROProperty("hwnd")

hwnd = Extern.GetMainWindow(hwnd , GA_ROOT)
msgbox Window("hwnd:=" & hwnd ).GetROProperty("minimized")

The above code returns False if the Tab/browser is maximized else
returns True if the Tab/browser is minimized

The above code worked well with QTP and IE 7.

How to compare two images using QTP

How to compare two images using QTP

We know by using Bitmap checkpoint, we can compare two images.

But is there a other way we can compare?

Yes, we can use "IsEqualBin" method from Mercury.FileCompare

sImgPath1="C:\Users\user\Downloads\SAI 01461_exposure.JPG"
'sImgPath2="C:\Users\user\Downloads\SAI 01462_exposure.JPG"
sImgPath2="C:\Users\user\Downloads\SAI 0175_exposure.JPG"
Set obj=createobject("Mercury.FileCompare")
retVal=obj.IsEqualBin(sImgPath1,sImgPath2,1,1)
print retVal
Set obj=nothing

The retVal=1 if both the images are same
else retVal=0

Friday, 12 January 2018

Webtable: Click on link irrespective of number of Webtables

Set objwt=description.Create
objwt("micclass").value="Webtable"
objwt("html tag").value="TABLE"

set allwt=Browser("Recovery Scenario Cases").Page("Recovery Scenario Cases_2").ChildObjects(objwt)

 print allwt.count
 For i = 0  To allwt.count-1 Step 1

 rownum=allwt(i).Getrowwithcelltext("January")

 If rownum>0 then

msgbox allwt(i).ChildItemCount(rownum, 3,"Link")
Set owebel=allwt(i).ChildItem(rownum,3,"Link",0)

msgbox typename(owebel)
owebel.Highlight
owebel.Click
 End if

 Next

Reverse String without changing position


str="my name is sumit"

arr=split(str," ")

result=""
for i=lbound(arr) to ubound(arr)

arr(i)=StrReverse(arr(i))
result=result&" "&arr(i)
next
 
msgbox result
 ' ym eman si timus

Thursday, 11 January 2018

Basic UNIX Commands

mkdir <directoryname>
->makes directory
*Names are case sensitive


Cd <directoryname>   ->to change directory
cd.. ->moves one step back

cd=>changes to home dirctory


mkdir -p test1/test2/test2

will create the hierarchy


mkdir -v test1/test2/test2d test1

will show messages like create

created test2
created test3

-----------
 mkdir test1 test2 test3
=>creates 3 directory

rmdir  test1
=>directory not empty

touch command
=>for creating empty file

touch file1

cat >file1

write sometjing 

cntl d


cat >>file1

write something
new data





ls==>listsls files and foldes

blue are directory
back are files


to see properties of files/folders
ls -l   shows multicolumn data


-d states dictionary
-  states its a file




pwd
=> Shows present working directory

ls
=>lists the contends

cp
=>copy

mv
=>move


grep

finding some text present in a file




locate

finding the file itself


touch
easy way to create new empty file


cat
for creating and appending to file


tar

chmod


history
Shows Previously used commands


finger
finfds info about logged in users









who=>logged in users

who am i=>ur identity


to know what shell u r using
echo $SHELL

type ps
=>tell where pgm for type is stored


ps is /bin/ps


clear clears screen

head

tail


Spring Boot : Exception Handler 14