Micro Focus QTP (UFT) Forums
How to check for a static text in a web page using desrciptive programming? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to check for a static text in a web page using desrciptive programming? (/Thread-How-to-check-for-a-static-text-in-a-web-page-using-desrciptive-programming)



How to check for a static text in a web page using desrciptive programming? - jaykisan - 09-19-2008

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


RE: How to check for a static text in a web page using desrciptive programming? - Ankur - 09-29-2008

Could you please format the code first using "edit" option given below the post..it's difficult to go through the unformatted post.


RE: How to check for a static text in a web page using desrciptive programming? - jaykisan - 10-14-2008

Hi Ankur,

Please find the formatted Code.

Thanks & Regards,
SatyaKiran Watts


RE: How to check for a static text in a web page using desrciptive programming? - upadhyay40 - 12-03-2009

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


RE: How to check for a static text in a web page using desrciptive programming? - Saket - 12-03-2009

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.