Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check for a static text in a web page using desrciptive programming?
#1
Solved: 11 Years, 3 Months, 4 Weeks ago Question 
Hi Ankur,

Please let me know to check for an expected static text in a web page without using the text checkpoint concept.
Currently, I was trying to create a driver script which can drive though the test cases written in excel.Please have a look and let me know for any suggestions/improvements etc.
Here is the script:
Code:
DataTable.AddSheet "TestCases"
DataTable.AddSheet "OR"
DataTable.AddSheet "StepResults"
DataTable.AddSheet"TestcaseResults"
DataTable.AddSheet"CheckpointResults"

DataTable.GetSheet ("StepResults").AddParameter "TestcaseName",""
DataTable.GetSheet ("StepResults").AddParameter "Result",""

DataTable.GetSheet ("TestcaseResults").AddParameter "TestcaseName",""
DataTable.GetSheet ("TestcaseResults").AddParameter "Result",""

DataTable.GetSheet ("CheckpointResults").AddParameter "TestcaseName",""
DataTable.GetSheet ("CheckpointResults").AddParameter "CheckpointName",""
DataTable.GetSheet ("CheckpointResults").AddParameter "Result",""

Datatable.importSheet "D:\Temp_Official\Satya\Plz dont open FinalFramework\ExcelEngine\TestCases.xls","TestCases","TestCases"
Datatable.importSheet "D:\Temp_Official\Satya\Plz dont open FinalFramework\ExcelEngine\AppMap.xls","OR","OR"
temp=1
j=1
k=1
bool=0

'create_or("E:\Aruna Official\aruna framework\ExcelEngine\AppMap.xls")
'update_testcases("D:\Temp_Official\Satya\Plz dont open FinalFramework\ExcelEngine\TestCases.xls")

Dim BrowserProperty,PageProperty,Object,ObjectProperty,i,x,BrowserName,ObjectName,PageName,z,temprc
temprc= DataTable.GetSheet("TestCases").GetRowCount
For i=1 to temprc Step 1
        DataTable.GetSheet("TestCases").SetCurrentRow(i)  
        If DataTable("TestcaseName","TestCases")<>"" Then
            temptc=DataTable("TestcaseName","TestCases")
            msgbox "Now about to run the test case :" &temptc
        End If
        'To place final test case result and exit
        If        DataTable("BrowserName","TestCases")="" Then
                DataTable.GetSheet("TestCases").SetCurrentRow(temp)
                DataTable.GetSheet("TestcaseResults").SetCurrentRow(j)
                If    bool=1 Then
                    DataTable("TestcaseName","TestcaseResults")=temptc
                    DataTable("Result","TestcaseResults")="Fail"
                    bool=0
                  Else
                    DataTable("TestcaseName","TestcaseResults")=temptc
                    DataTable("Result","TestcaseResults")="Pass"
                 End If
                     j=j+1
                    temp=i+1
                 Exit For
        End If
        'For Check-Points
        Select Case DataTable("Action","TestCases")
            Case "check_link"
                check_link_save_delete()
            Case "check_error"
                check_error()
            Case "check_login"
                check_login()
        End Select
        'For Object-Identification    
        Select Case DataTable("Object","TestCases")

                        set BrowserName=description.create
                        BrowserName=DataTable("BrowserDescription","OR")
                        set PageName=description.create
                        PageName=DataTable("PageDescription","OR")
                        set ObjectName=description.create
                        ObjectName=DataTable("ObjectDescription","OR")
                        
        Case "WebEdit"
                If        DataTable("Action","TestCases")="InputText" Then
                        Browser(BrowserName).Page(PageName).WebEdit(ObjectName).Set DataTable("Value","TestCases")
                End If
        Case "WebButton"
                If        DataTable("Action","TestCases")="Click" Then
                        set BrowserName=description.create
                        BrowserName("title").value=DataTable("BrowserName","TestCases")
                        set ObjectName=description.create
                        ObjectName("value").value=DataTable("ObjectName","TestCases")
                        set PageName=description.create
                        PageName("title").value=DataTable("PageName","TestCases")
                        Browser(BrowserName).Page(PageName).WebButton(ObjectName).Click
                End If
         Case "WinButton"
                If        DataTable("Action","TestCases")="Click" Then
                        set BrowserName=description.create
                        BrowserName("name").value=DataTable("BrowserName","TestCases")
                        set ObjectName=description.create
                        ObjectName("text").value=DataTable("ObjectName","TestCases") 'regexpwndtitle
                        set PageName=description.create
                        PageName("text").value=DataTable("PageName","TestCases")
                        Browser(BrowserName).Dialog(PageName).WinButton(ObjectName).Click 'Type micReturn
                End If
        Case "ImageButton"
                If        DataTable("Action","TestCases")="Click" Then
                        set BrowserName=description.create
                        BrowserName("title").value=DataTable("BrowserName","TestCases")
                        set PageName=description.create
                        PageName("title").value=DataTable("PageName","TestCases")
                        set ObjectName=description.create
                        ObjectName("html id").value=".*"&DataTable("ObjectName","TestCases")
                        Browser(BrowserName).Page(PageName).Image(ObjectName).Click
                End If
        Case "WebList"
                 If        DataTable("Action","TestCases")="Select" Then
                         set BrowserName=description.create
                        BrowserName("title").value=DataTable("BrowserName","TestCases")
                        set PageName=description.create
                        PageName("title").value=DataTable("PageName","TestCases")
                        set ObjectName=description.create
                        ObjectName("html id").value=".*"&DataTable("ObjectName","TestCases")
                        Browser(BrowserName).Page(PageName).WebList(ObjectName).Select DataTable("Value","TestCases")
               End If
        Case "WebLink"
                If        DataTable("Action","TestCases")="Click" Then
                        set BrowserName=description.create
                        BrowserName("title").value=DataTable("BrowserName","TestCases")
                        set PageName=description.create
                        PageName("title").value=DataTable("PageName","TestCases")
                        set ObjectName=description.create
                        ObjectName("name").value=".*"&DataTable("ObjectName","TestCases")&".*"
                        Browser(BrowserName).Page(PageName).Link(ObjectName).Click
                End If
        End Select
    'Step wise results
            stat=""
             Select Case Reporter.RunStatus
                 Case 0
                            stat="Pass"
                 Case 1
                           bool=1
                           stat="Fail"
                 Case 2
                            stat="Done"
                 Case 3
                            stat="Warning"
             End Select
             DataTable.GetSheet("StepResults").SetCurrentRow(i)
             DataTable("TestcaseName","StepResults")=DataTable("TestcaseName","TestCases")
             DataTable("Result","StepResults")=stat
    'Check point wise results
             If        mid((DataTable("Action","TestCases")),1,5)="check" Then
                     DataTable.GetSheet("CheckpointResults").SetCurrentRow(k)
                     DataTable("TestcaseName","CheckpointResults")=temptc
                     DataTable("CheckpointName","CheckpointResults")=DataTable("Action","TestCases")
                     DataTable("Result","CheckpointResults")=stat
                     k=k+1
             End If
    'Test case wise results
         DataTable.GetSheet("TestCases").SetCurrentRow(i+1)
         If        DataTable("TestcaseName","TestCases")<>"" Then
                DataTable.GetSheet("TestCases").SetCurrentRow(temp)
                DataTable.GetSheet("TestcaseResults").SetCurrentRow(j)
                 If bool=1 Then
                        DataTable("TestcaseName","TestcaseResults")=temptc
                        DataTable("Result","TestcaseResults")="Fail"
                        bool=0
                Else
                        DataTable("TestcaseName","TestcaseResults")=temptc
                        DataTable("Result","TestcaseResults")="Pass"
                End If
                 j=j+1
                temp=i+1
        End If
Next
Datatable.ExportSheet "D:\Temp_Official\Satya\Plz dont open FinalFramework\ExcelEngine\Results.xls","StepResults"
Datatable.ExportSheet "D:\Temp_Official\Satya\Plz dont open FinalFramework\ExcelEngine\Results.xls","TestcaseResults"
Datatable.ExportSheet "D:\Temp_Official\Satya\Plz dont open FinalFramework\ExcelEngine\Results.xls","CheckpointResults"

Thanks in Advance,
SatyaKiran Watts
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Could you please format the code first using "edit" option given below the post..it's difficult to go through the unformatted post.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi Ankur,

Please find the formatted Code.

Thanks & Regards,
SatyaKiran Watts
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi SatyaKiran/Ankur

I am new to QTP, i my self implement QTP in my organization, i did a lot, but i dint aware about the concept of datadriven testing (I have theoretical knowledge), can you please give me or send me the whole framework demo so i will look at into it and implement on my end, please take in consider this, hoping for your kind cooperation. My mail id upadhyay40@gmail.com

Thanks

Mahesh
Hi SatyaKiran,

You done a excellent job, please send me the framework so i can explore my knowledge, looking for kind response.

Thanks
Mahesh
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi Mahesh,
always create a new thread for your query, don't divert a thread posting your query in between a thread which is not relevant to the orignal query.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can QTP handle slick grid table in a web page qtplearner88 2 4,508 10-01-2019, 10:44 AM
Last Post: shilpi952
  DP Web Browser/Page issues rstimers 1 2,452 08-14-2015, 12:37 PM
Last Post: venkatesh9032
  Using static descriptive programming how to count no. of objects on any webpage alpha1 4 6,989 08-11-2015, 08:48 PM
Last Post: kotaramamohana
  How to Verify Static Object Text which is changing Dynamically with Expected Result johnny77 0 3,305 06-25-2015, 11:32 AM
Last Post: johnny77
  check broken link in a page deveshbhatt29 0 2,771 01-18-2014, 12:35 PM
Last Post: deveshbhatt29

Forum Jump:


Users browsing this thread: 1 Guest(s)