Wednesday, October 25, 2017

Description Programming

'==Descriptive Programming language
'creating the common browser and page object 
Set myPage= browser("creationtime:=0").page("title:=.*")
'creating ll Description objects 
'it contacins all th eobjects present in webpage
Set desc=Description.Create


' getting all childobjects 
set allPageObjects=myPage.ChildObjects(desc)
'priting all the objects from the page.//total count
print allPageObjects.count

'here we use micclass to get the property of classname'micclass

For i = 0 To allPageObjects.count-1 Step 1
    print "object *****"&i
    print allPageObjects(i).getroproperty("micclass")&"-----"&allPageObjects(i).getroproperty("visible")
Next
'print allPageObjects(0).getroproperty("micclass")
'-----------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------


'==Descriptiv language
'creating the common browser and page object
Set myPage= browser("creationtime:=0").page("title:=.*")
'creating ll Description objects
'it contacins all th eobjects present in webpage
Set desc=Description.Create


'filter TO GET PARTICULAT WEB ELEMENT


' to display the objects of only webedits
'desc("micclass").value="WebEdit"

'to get the complete Links
'desc("micclass").value="Link"

'to get the complete Links
desc("micclass").value="WebList"

' getting all childobjects
set allPageObjects=myPage.ChildObjects(desc)
'priting all the objects from the page.//total count
print "Totol number of objects are :-"&allPageObjects.count


'specific object from the page*******
'print allPageObjects(0).getroproperty("micclass")



'here we use micclass to get the property of classname'micclass

For i = 0 To allPageObjects.count-1 Step 1
    'print "object *****"&i
    print allPageObjects(i).getroproperty("micclass")&"-----"&allPageObjects(i).getroproperty("innertext")
Next



allPageObjects(0).SELECT ("Jan")

'Calling the function to get links
WebelementCount "Link"

Function WebelementCount(webelement)

    Set myPage= browser("creationtime:=0").page("title:=.*")
    Set desc=Description.Create
    desc("micclass").value=webelement
    set allPageObjects=myPage.ChildObjects(desc)

print "Totol number of objects are :-"&allPageObjects.count
For i = 0 To allPageObjects.count-1 Step 1
    print allPageObjects(i).getroproperty("micclass")&"-----"&allPageObjects(i).getroproperty("innertext")
Next
End Function


'-------------------------------------------------------------------------------------------------------------


'google links
Set myPage= Browser("creationtime:=0").Page("title:=.*")
set desc=Description.Create
desc("micclass").value="Link"
desc("height").value=21
set objLink=myPage.ChildObjects(desc)
print objLink.count

For i = 1 To objLink.count Step 1
    print objLink(i).getroproperty("innertext")
Next


'-----https://demo2.odoo.com/web#view_type=list&model=sale.order&menu_id=487&action=719
'demo2.
Set myPage=Browser("creationtime:=0").Page("title:=.*")
Set desc=Description.Create
desc("micclass").value="WebCheckBox"
desc("height").value=15
set ObjWebCheckBox=myPage.ChildObjects(desc)
print ObjWebCheckBox.count
ObjWebCheckBox(0).click



'---------**********************************************************************

'https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select
'Weblist
Set desc= Description.Create
desc("micclass").value="WebList"
desc("height").value=21

Set myPage=Browser("creationtime:=0").Page("title:=.*").ChildObjects(desc)

myPage.count
myPage(0).CaptureBitmap "f:\list.png",true
myPage(0).select(1)
'or
myPage(0).GetItem(3)


'*******************************************************************************88


Set box = Browser("creationtime:=0").Page("title:=.*").WebElement("class:=signin-box")

Set desc = description.Create
desc("micclass").value="WebEdit"

Set objEdits = box.ChildObjects(desc)
print " Total edit boxes -> "& objEdits.count
objEdits(0).set "username"
objEdits(1).set "password"



desc("micclass").value="WebButton"
Set objButton = box.ChildObjects(desc)
print "Total buttons -> " & objButton.count
print objButton(0).getroproperty("value")
'objButton(0).click


desc("micclass").value="WebCheckBox"
Set objCheckBox = box.ChildObjects(desc)
If  objCheckBox(0).getROProperty("checked") = 0 Then
objCheckBox(0).click
End If


'------
********************************************************************



'rediff mail 

Set desc =Description.Create
Set myPage=Browser("creationtime:=0").Page("title:=.*").WebElement("class:=login-form")
Set desc =Description.Create
desc("micclass").value="WebEdit"
Set objectWebEdit=myPage.ChildObjects(desc)
print "the total number of edit fields are:-"&objectWebEdit.count

'*********************************************************************
' entering values into username and password


objectWebEdit(0).set "sud3eer@rediffmail.com"
objectWebEdit(1).set "Kewl@080288"

'************************************************************************
'click on button now:-

desc("micclass").value="WebButton"
Set objectWebbutton=myPage.ChildObjects(desc)
print objectWebbutton(0).getroproperty("value")
objectWebbutton(0).click



'******************************************************************
'https://www.quikr.com/
' extracting from the boxes

Set myPage= Browser("creationtime:=0").page("title:=.*")
Set desc=description.Create
desc("micclass").value="WebElement"
desc("class").value="col-sm-4 col-md-4"

set categories=myPage.ChildObjects(desc)
print categories.count

Set desc_link= description.Create
desc_link("micclass").value="Link"



For j = 0 To categories.count-1
print"**********************"
set chilobj=categories(j).childObjects(desc_link)
'print "total links are -->"&chilobj.count
For k = 0 To chilobj.count-1
'extracting links from a box
'print chilobj.count
    print chilobj(k).GetRoProperty("innertext")
Next
   
Next

'************************************************************************
'  Working with object with in the object
'Exporting 
 datatable.AddSheet "quikr"'---adding excel sheet quikr
set myPage = Browser("creationtime:=0").Page("title:=.*")
Set descCategories = description.Create
descCategories("micclass").value="WebElement"
descCategories("html id").value = "cats"
Set categories= myPage.ChildObjects(descCategories)
print categories.count
Set desc_link = description.Create
desc_link("micclass").value= "Link"
Dim col_name
' category
For i=0 to categories.count-1
    col_name = "Category_"& i

' adding column wise i.e boxes
datatable.GetSheet("quikr").AddParameter col_name,""
    print "***********************************************"
Set objLink = categories(i).childObjects(desc_link)
' links
print "Total Links -> " & objLink.count
    For j=0 to objLink.count-1
        datatable.GetSheet("quikr").SetCurrentRow(j+1)
        linktext= objLink(j).getROProperty("innertext")   
        print linktext
        datatable(col_name,"quikr")=linktext
    Next
Next
datatable.ExportSheet "C:\quikr.xls","quikr"

'-----------------------------------------------------------------------------------------------------------





Tuesday, October 24, 2017

Actions:


 browser("Rediffmail").Navigate("https://mail.rediff.com/cgi-bin/login.cgi")
Browser("Rediffmail").Page("Rediffmail").WebEdit("login").Set "sud3eer@rediffmail.com"
Browser("Rediffmail").Page("Rediffmail").WebEdit("passwd").Set "Kewl@080288"
Browser("Rediffmail").Page("Rediffmail").WebButton("Go").Click
1. Save a test--reusableaction
2. Save again test as reusableaction_test
3.call in script:call to existing action.(it is not editable)-it cn be open when u call direct test.
run the below one it will execute complete login.
 RunAction "Action1 [ReusableActions_test]", oneIteration

Monday, October 23, 2017

Compare rows from sheets

' adding T1 and T2 sheets to datatable

datatable.AddSheet "T1"
datatable.AddSheet "T2"

' iporting sheets to datattable
datatable.ImportSheet "F:\qtp2.xls","T1","T1"
datatable.ImportSheet "F:\qtp2.xls","T2","T2"
datatable.AddSheet "Result"
' clling fuction
compare("Name")
compare("Email")

'exporting results to excel
datatable.ExportSheet "F:\qtp2.xls","Result"

Function compare(colName)
datatable.GetSheet ("Result").AddParameter colName,""
' which col has max rows
rows=0
If datatable.GetSheet("T1").GetRowCount > datatable.GetSheet("T2").GetRowCount Then
    rows = datatable.GetSheet("T1").GetRowCount
else
    rows = datatable.GetSheet("T2").GetRowCount
End If

For i=1 to rows
    datatable.GetSheet("T1").SetCurrentRow(i)
    datatable.GetSheet("T2").SetCurrentRow(i)
    datatable.GetSheet("Result").SetCurrentRow(i)
    If datatable(colName,"T1") <> datatable(colName,"T2") Then
        datatable(colName,"Result") ="N"
    else
        datatable(colName,"Result") ="Y"
    End If
Next

End Function

DataTable_Importing[import from existing sheet to new sheet]

'Importing Datatable
datatable.AddSheet ("TestData")' if we want to import own sheet first we need to add sheet
datatable.import "F:\qtp2.xls" ' it import global and ation sheets


datatable.GetSheet("Action1").SetCurrentRow(4) 'the cursor is at row 4
print datatable ("Country","Action1") 'it will print the cursor row from action1 sheet and country column

'******************************************************

'Importing sheet from source to destination sheet!/importing existing sheet to new sheet
datatable.AddSheet("currentTest")' Adding the Sheet -currentTest
datatable.ImportSheet "F:\qtp2.xls","TestData","currentTest"'Adding the testData sheet to currentTest sheet
datatable.GetSheet("currentTest").SetCurrentRow(5)'cursor will be at 5th row
print datatable ("Test","currentTest")'priting the data of Test column in currentTest

'*************************************************


DataTable_Local Sheet Read Write and Export

'************************'Local data table*****************************

'To get the total rowCount  from Action1 Sheet


print datatable.GetSheet("Action1").GetRowCount
'*******************************************************
' Reading the data and wrting 

For i = 1 To datatable.GetSheet("Action1").GetRowCount Step 1
    datatable.GetSheet("Action1").SetCurrentRow(i)
    print datatable("Country","Action1")' read the data of Action1 of country column
    datatable("Test","Action1")=i 'Writes to the Action1 of Test Column
    ' in test column it will display 1,2,3,4.
Next
'wait 15

'*****************************************************
'Adding the column in Local Sheet
datatable.GetSheet("Action1").AddParameter "Col4","1234"
'if script complete column will be flashed out,see in test result window.
'wait 5

'*******************************************8
'Add own sheet in Datatable

datatable.AddSheet("TestData")                             ' Adding the Sheet to datattable
datatable.GetSheet("TestData").AddParameter "Test",""     'created a column in sheet "TEST
datatable.GetSheet("TestData").SetCurrentRow(5)            'writing in 5th column to the sheet TestData/Test
datatable("Test","TestData")="XXXXXXXX"                 'Writing data as XXXXXXX 
                                       
'******************************************************************
'Export complete datatble to xls file 2003
' in qtp only xls files are supported
' here old exported file will be deleted add new data will be appended


' to export complete datatable
datatable.Export "f:\qtp2.xls"
'to export particulat sheet from excel.
datatable.ExportSheet "f:\qtp2.xls","Action1"


                                       

Data Table-Global_reading_Writing

'Data Table
'Reading data from data table

'In data table 2 sheets 

'Global:-
'Local sheet:-

' change in---> setting --->Run--> RUN WITH ONE ITERATION ONLY

'****** Interact with GLOBAL sheet**********
print "start"
'open browser
'loggedin
print datatable("Name")' row 1 
datatable.SetCurrentRow(2)' cursor move to next
print datatable("Name")
datatable.SetCurrentRow(3)
print datatable("Name")
print "end"

' retrive all data using for loop
For i = 1 To datatable.GetRowCount Step 1
    print datatable("Name")
    datatable.SetCurrentRow(i)
    datatable("Country")="India"' wrting data on country column ie INDIA
Next
wait 5 ' it will wait to see the data india in coutry column ,

 'to know the total number of rows
 print datatable.GetRowCount


 'Writing data to datatable

 For i = 1 To 10 Step 1
     datatable.SetCurrentRow(i)
    datatable("Col1")=i                     ' it will write 1 to 10 in col1 
    datatable("Col2")=11-i          ' it will write 10 to 0 in colmn 2
    datatable("Col3")=cint(datatable("Col1"))+cint(datatable("Col2")) 'Adding column 1 and coulumn '2
 
 Next

wait 25

'IN DATATABLE MODIFICATIONS WONT DISPLAY ,IT WILL DISPLAY TILL THE TIME OF SCIPT RUNNING,ONCE SCRIPT END IT WILL 
'DISCARD,TO SEE THAT SEE IN RESULT WINDOW

' to add the column to the global sheet
 datatable.GlobalSheet.AddParameter "Test_Col",""
 wait 10'

Compare RO and TO properties

  'http://www.w3schools.com/html/default.asp

 bResult = bResult & "<table border=1><tr><th>" & _
                    "Status</th><th>Property</th><th>Expected</th><th>Actual</th></tr>"

Set allProp = Browser("HTML Tutorial").Page("HTML Tutorial").WebButton("Search").GetTOProperties
isPass=true
For i=0 to allProp.count -1
    expected = allProp(i).value
    actual = Browser("HTML Tutorial").Page("HTML Tutorial").WebButton("Search").GetROProperty(allProp(i).name)

    If trim(expected) <> trim(actual) Then
        bResult = bResult & "<tr><td>" & _
                            "Fail" & "</td><td>" & _
                            allProp(i).name & "</td><td>" & _
                            expected & "</td><td>" & _
                            actual & "</td></tr>"
        isPass=false
    else
        bResult = bResult & "<tr><td>" & _
                            "Pass" & "</td><td>" & _
                            allProp(i).name & "</td><td>" & _
                            expected & "</td><td>" & _
                            actual & "</td></tr>"
    End If
Next



Set StepInfo = CreateObject("Scripting.Dictionary")
StepInfo("ViewType") = "Sell.Explorer.2"
StepInfo("DllIconIndex") = 209
StepInfo("DllIconSelIndex") = StepInfo("DllIconIndex")
StepInfo("DllPAth") = Environment.Value("ProductDir") & "\bin\ContextManager.dll"

If isPass Then
    StepInfo("Status") = micPass
else
    StepInfo("Status") = micFail
End If


StepInfo("NodeName") = "Result page name"

StepInfo("StepHtmlInfo") = "<html>" & bResult & "</body></html>"



    Reporter.LogEvent "User", StepInfo, Reporter.GetContext

  

'''''''''''''''''''''''''''''''''''''''''''''''''''FUNCTION''''''''''''''''''''''''''''''''''''''''''''

Set o =Browser("HTML Tutorial").Page("HTML Tutorial").WebButton("Search")
validateObjectProperties o,"search Button Validation"

Set o = Browser("HTML Tutorial").Page("HTML Tutorial").Link("HTML Formatting")
validateObjectProperties o,"Html Formatting Link"

Set x = Browser("The Times of India: Latest").Page("The Times of India: Latest").Frame("Frame").WebElement("1 + 5 =")
validateObjectProperties x,"TOI Link"



Function validateObjectProperties(object,stepName)

   bResult = bResult & "<table border=1><tr><th>" & _
                    "Status</th><th>Property</th><th>Expected</th><th>Actual</th></tr>"

Set allProp = object.GetTOProperties
isPass=true
For i=0 to allProp.count -1
    expected = allProp(i).value
    actual = object.GetROProperty(allProp(i).name)

    If trim(expected) <> trim(actual) Then
        bResult = bResult & "<tr><td>" & _
                            "Fail" & "</td><td>" & _
                            allProp(i).name & "</td><td>" & _
                            expected & "</td><td>" & _
                            actual & "</td></tr>"
        isPass=false
    else
        bResult = bResult & "<tr><td>" & _
                            "Pass" & "</td><td>" & _
                            allProp(i).name & "</td><td>" & _
                            expected & "</td><td>" & _
                            actual & "</td></tr>"
    End If
Next



Set StepInfo = CreateObject("Scripting.Dictionary")
StepInfo("ViewType") = "Sell.Explorer.2"
StepInfo("DllIconIndex") = 209
StepInfo("DllIconSelIndex") = StepInfo("DllIconIndex")
StepInfo("DllPAth") = Environment.Value("ProductDir") & "\bin\ContextManager.dll"

If isPass Then
    StepInfo("Status") = micPass
else
    StepInfo("Status") = micFail
End If


StepInfo("NodeName") = stepName

StepInfo("StepHtmlInfo") = "<html>" & bResult & "</body></html>"

Reporter.LogEvent "User", StepInfo, Reporter.GetContext



End Function








Sunday, October 22, 2017

Reports-Calender

' reporting functions:-
'------BAsic reporting status
'print micPass                 ' 0- passing
'print micFail                 '1-Fail
'print micDone                 '2 -Done
'print micGeneral             '2-General
'print micWarning             '3=Warning



Set myPage= Browser("creationtime:=0").page("page:=.*")
Reporter.ReportNote "opened the URL of application"
Browser("creationtime:=0").Navigate "http://www.rediff.com/"
myPage.Link("innertext:=Money").Click
myPage.Link("innertext:=My Portfolio","index:=0").Click
myPage.WebEdit("html id:=useremail").Set "sud3eer@rediffmail.com"
myPage.WebButton("html id:=emailsubmit").Click
myPage.WebEdit("html id:=userpass").Set "Pass@123"
myPage.WebButton("html id:=loginsubmit").Click

Reporter.ReportNote "loggedIN"' customized nore to reports
expectedName="sudheer reddy"

'myPage.Link("innertext:="&expectedName).GetRoProperty("name")
profileLinkExist= myPage.Link("innertext:="&expectedName).Exist
print profileLinkExist

' what is the status 
print Reporter.RunStatus
If profileLinkExist Then
Reporter.ReportEvent micPass,"LoginStatus","Login was successfull"
else
Reporter.ReportNote "Unsuccesfull to login" ' it will add to the reports as a NOTE
    mypage.CaptureBitmap "C:\error.png",true ' capture the screen short
    Reporter.ReportEvent micFail,"LoginStatus","Login was not successfull","C:\error.png"
    ExitRun 'if fails it will stop the execution
  
  
End If

print Reporter.RunStatus ' it will help to know the statusof reports
'reporter.ReportPath' it wil display the path of reportes stored

'reporter.Filter= rfDisabledAll' it is used to stop reporting on the script / it will ignore all reporter object
'reporter.Filter= rfEnabledAll ' it will enable to reporter objects and we can see in results



'Set myPage= Browser("creationtime:=0").page("page:=.*")
myPage.WebButton("html id:=addStock").Click
myPage.WebEdit("html id:=addstockname").Set "Bajaj Auto Ltd."
myPage.Link("html id:=stockPurchaseDate").Click

'---------------calender date selection


'Set myPage= Browser("creationtime:=0").page("page:=.*")
msgbox date
'UFT default data mm/dd/yyyy
selectDate cdate("10/21/2019")
myPage.WebEdit("html id:=addstockqty").Set "10"
myPage.WebEdit("html id:=addstockprice").Set "10"
myPage.WebElement("innertext:=NSE","index:=0").Click
myPage.WebElement("html id:=exchange_tab").Click



'FUNCTION FOR below if current date is less than datetobeSelected,greater than datetobeSelected,is qual to datetobeSelected

Function selectdate(datetobeSelected)
    currentDate=date
    diff=dateDiff("m",currentDate,datetobeSelected)
    print diff
  
    While (diff<>0 )
        If diff< 0 Then
        myPage.WebButton("innertext:=\<").Click
        currentDate=dateadd("m",-1,currentdate)
        ElseIf diff>0 Then
        myPage.WebButton("innertext:=\>").Click
            currentDate=dateadd("m",1,currentdate)
        End If
        diff=dateDiff("m",currentDate,datetobeSelected)  
    Wend
    myPage.WebElement("innertext:="&day(datetobeSelected)).click
'    Reporter.ReportEvent 
  
End Function

Saturday, October 21, 2017

WebTable

http://money.rediff.com/gainers/bse/daily/groupa?src=gain_lose

' capture total data table using SET into table
set table=Browser("creationtime:=0").Page("title:=.*").WebTable("class:=dataTable")

' to get the complete rows in a data table
TotalRows=table.RowCount

'to get columns of rows ,here 1 is 1st row
TotalColms=table.ColumnCount(1)

print "totals rows are "&TotalRows
print "Totals columns are "&TotalColms

print table.GetCellData(5,1)

' to get data of complete first column
print "****ROWS ITERATION***********"
For rowNum = 1 To TotalRows Step 1
    print table.GetCellData(rowNum,1)
Next

'to get the data of selected row all colums,here selected 5 row all columns
print "****column ITERATION***********"

For ColNum = 1 To TotalColms Step 1
    print table.GetCellData(5,ColNum)
Next

print "****TABLE ITERATION***********"

'to get data of complete data table

For rowNum = 1 To 5 Step 1
    print "***Print data :---"&rowNum

For ColNum = 1 To TotalColms Step 1
    print table.GetCellData(rowNum,ColNum)
Next
Next

companyName="MothersonSumiSystems"
 'it will also get row with cell data text.User defined function
For rNum = 1 To rows Step 1
cname=trim(table.GetCellData(rNum,1))
print cname & "------"&strcomp(cname,companyName)
If strcomp(cname,companyName)=0 Then
    print table.GetCellData(rNum,4)
    Exit for
End If
    Next
-------------------------------------------------------------------------
'Using of Functions := inbuilt function.
'GetRowWithCellText(companyName)
'GetCellData(runum,4)
set table=Browser("creationtime:=0").Page("title:=.*").WebTable("class:=dataTable")
companyName="MothersonSumiSystems"
runum= table.GetRowWithCellText(companyName)
print table.GetCellData(runum,4)

POPUP's/TABS

'Links opened in new tab/POPUP


Set myPage=Browser("creationtime:=0").Page("title:=.*")
myPage.WebElement("title:=Support the jQuery Foundation","index:=1").Click

'New Tab
Set myPage2=Browser("creationtime:=1").Page("title:=.*")
myPage2.WebElement("name:=Blog","index:=0").Click
myPage2.CaptureBitmap "E:\QTP\TABS.png",True
'Browser("Donate – JS Foundation").Page("Donate – JS Foundation").Link("Home").Click

'----------------*****************--------------------
myPage2.WebEdit("name:=user[name]"). set "sud3eer"
'this will not accept by qtp so user\[name\]

Without Using Object Repository

'Browser("name:=Amazon Sign In").Page("title:=Amazon Sign In").WebEdit("name:=email").Set "sud3eer"

Browser("creationtime:=1").Page("title:=Amazon Sign In").WebEdit("name:=email").Set "sud3eer@gmail.com"
Browser("creationtime:=1").Page("title:=Amazon Sign In").WebEdit("name:=password").Set "Kewl@080288"
Browser("creationtime:=1").Page("title:=Amazon Sign In").WebButton("name:=Submit Query").Click

'Using Regular Expressions:-

Browser("creationtime:=1").Page("title:=.*").WebEdit("name:=email").Set "sud3eer@gmail.com"
Browser("creationtime:=1").Page("title:=.*").WebEdit("name:=password").Set "Kewl@080288"
Browser("creationtime:=1").Page("title:=.*").WebButton("name:=Submit Query").Click

'Using Regular Expression (.*)
Browser("creationtime:=1").Page("title:=.*").Link("name:=.*Orders 7.*").Click

'intializing the Browser/Page to myPage-GENERIC PAGE
Set myPage= Browser("creationtime:=1").Page("title:=.*")


myPage.WebEdit("name:=email").Set "sud3eer@gmail.com"
myPage.WebEdit("name:=password").Set "Kewl@080288"
myPage.WebButton("name:=Submit Query").Click
myPage.Link("name:=.*Orders 7.*").Click

'ADDING 2 PROPERTIES"
Set myPage= Browser("creationtime:=1").Page("title:=.*")
myPage.WebEdit("html id:=uh-search.*","acc_name:=Search").Set "LatestNews"

'Total  Opened Browsers:-
browserCount=0
While Browser("creationtime:="&browserCount).Exist
    browserCount=browserCount+1
Wend

print "BrowserCount"& browserCount


'closing all browsers:

While Browser("creationtime:=0").Exist
    Browser("creationtime:=0").Close
Wend

Thursday, October 19, 2017

Real Time

     'to get the list of items from the drop down list


https://www.amazon.com/gp/history/ref=nav_nav_timeline_view_history

totalcount=Browser("browser").Page("page").WebList("dropdown").GetROProperty("items count")
print totalcount

For i = 1 To totalcount Step 1
    print Browser("browser").Page("page").WebList("dropdown").GetItem(i)
Next


---------------------------------------------------------------------------------------

'MULTISELECT LIST

'print idex value for MULTISELECT
indexcars=Browser("browser").Page("Tryit Editor v3.5").Frame("iframeResult").WebList("cars").GetROProperty("selected item index")
print indexcars&":----Index alue of car are "


'print Values for MULTISELECT
cars=Browser("browser").Page("Tryit Editor v3.5").Frame("iframeResult").WebList("cars").GetROProperty("value")
print cars&":-----list of cars are "


'-------------------------------------------------------------------------------------

'capturing the screenshot!

Browser("browser").Page("Page").CaptureBitmap "E:\QTP\temp.png",True


Browser("Micromax Canvas 5 Lite").Page("Micromax Canvas 5 Lite").Link("Have a question?").CaptureBitmap "E:\QTP\tempa.png",True


--------------------------------------------------------------------------------------
' using with out OR
'open the 1st browser then it will be 0.

'print Browser("creationtime:=0").GetROProperty("application version")
'print Browser("creationtime:=1").GetROProperty("application version")
'print Browser("creationtime:=2").GetROProperty("application version")


'----------------------------------------------------------
with out using Object repository!!




print Browser("creationtime:=0").Page("title:=Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more").GetROProperty("url")
print Browser("creationtime:=0").Page("title:=Amazon.com: Yahoo").GetROProperty("url")

Wednesday, October 18, 2017

Miscellinious

Optionalstep:  somtime you get add on page and other time tou wont then ,you can add optionstep before the code like.

optionalstep.Browser("Mozilla").Navigate "https://www.facebook.com/"



To get  the property of runtime object:
 print  Browser("Browser_mozilla").Page("Page").WebEdit("SearchBox").GetRoProperty("value")

' read the runtime properties

'identofication property

print  Browser("Browser_mozilla").Page("Page").WebEdit("SearchBox").GetRoProperty("value")

'native property
print  Browser("Browser_mozilla").Page("Page").WebEdit("SearchBox").Object.baseURI

---------------------------------------------------------------------------
 text= Browser("BBC browser").Page("BBC - page").WebElement("Welcomdate").GetROProperty ("innertext")
print text


welcomeMessage=left(text,18)
print welcomeMessage
welcome="Thursday, 19 October"
Bbcdate= right(text,20)
print Bbcdate
print welcome
If Bbcdate=welcome Then
    print "pass"
    else
    msgbox "fail"
End If
msgbox Browser("BBC browser").Page("BBC - page").WebElement("Welcomdate").GetTOProperty("innertext")

msgbox Browser("Browser").Page("page-TOI").WebElement("CurrentDateTime").GetTOProperty("innertext")


-----------------------------------------------------------------------------------------------------------

Tuesday, October 17, 2017

Basic Excel

'----WORKING WITH EXCEL

'CREATING OBJECT FOR EXCEL
'Optional explicit
'Dim objXls,fso,exclfile,sheet1,sheet2,existingsheet
'
'
'file_path="f:\testApp.xls"
'Set objXls= createobject("Excel.application")
''mAKING EXCEL FILE VISIBLE,SO THAT IT OPENS ELSE IT WILL DO OPERATION BACK END
'objXls.Visible=false
'
''---- it will check whether the file exist in the path,if not it will create a file else it will delete and create a new file.
'Set fso= createobject("Scripting.filesystemobject")
'
'If not fso.FileExists(file_path) Then
'set myxls=objXls.Workbooks.Add
'else
''delete the file and ccreate a new workbook
'fso.DeleteFile file_path
'set myxls=objXls.Workbooks.Add
'End If
'
''---creating the excel file
'Set exclfile=objXls.Workbooks.Add
'
'
''ADDING SHEET1 TO EXCEL
'set sheet1=exclfile.Sheets.Add
'sheet1.Name ="SystemTest"
''ADDING SHEET2 TO EXCEL
'set sheet2=exclfile.Sheets.Add
'sheet2.Name ="RegresstionTest"
'
''delete SystemTest sheet
'sheet2.Delete
'
''deleting existing sheet
'Set existingsheet=exclfile.sheets("sheet1")
'existingsheet.delete
'
'
'sheet1.Cells(2,3).value="city"' writing on cells
'
'sheet1.Cells(5,5).value="=Hyperlink("&chr(34)&"f:\xls\temp.png"&chr(34)&","&chr(34)&"click"&chr(34)&")"'--here we are adding hyperlink image to ecel cell(5,5)
'msgbox sheet1.Cells(2,3).value
'
'    
'
'' if u want to override the data in cells 
'objXls.DisplayAlerts=false
'exclfile.SaveAs "f:\testApp.xls"'--------------2003
'exclfile.SaveAs "f:\testApp.xlsx"'-------------------2007
'exclfile.Close'--close the excel file
'objXls.Quit '--quit the excel application
'
'
'calling a function using below function name
'readData
'writeData
'

Description Programming

'==Descriptive Programming language 'creating the common browser and page object  Set  myPage= browser( "creationtime:=0...