Results 1 to 7 of 7

Thread: How to match data of a table and list box using QTP? Pls answer immidiately.

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    3

    Question How to match data of a table and list box using QTP? Pls answer immidiately.

    Hi,
    I'm testing an web application using QTP9.0.in a page of application containing various listboxes with data and some editable blank text fields with an ADD button. After giving all valid values and clicking add button allthese given data is displayed in a table format under their respective columns in another web page. Please tell me how to match these column and cell values with the given data using QTP9.0?


  2. #2
    Expert Member
    Join Date
    Jan 2007
    Answers
    211

    Re: How to match data of a table and list box using QTP? Pls answer immidiately.

    Dim a(<>)

    ''Hold all the to be added Item in the Array/ Use the ListBox Entires at RunTime.

    intCnt = Browser(b).Page(p).Frame(f).WebList(W).getROProperty("items count")

    ''Once u have added the Items Using the Add Functionality (Comparision?)

    For LCnt = 0 to intCnt-1

    '''Hold the Data from the Table
    strTMP = Browser(b).Page(p).Frame(f).WebTable(w).GetCellData(LCnt +1,1)
    ''Assuming that the added data is reflected in the First Column
    if strComp(strTMP,a(LCnt) = 0 then
    Reporter.ReportEvent micPass,"SUCCESS","SUCESS"
    else
    Reporter.ReportEvent micFail,"FAILURE","FAILURE"

    end if

    Next




    Regards,
    Nawab


  3. #3
    Junior Member
    Join Date
    Apr 2008
    Answers
    4

    Re: How to match data of a table and list box using QTP? Pls answer immidiately.

    You can verify the added data in listbox using getcelldata method.
    example:
    say you added 3 data fields(x1,x2,x3) in the page and click on add button.Then you have verify the added data i.e. x1,x2,x3 in listbox in next page. for this
    get the 1st column data of added row and verify with x1.
    xx=Browser(b).Page(p).Frame(f).WebTable(w).GetCellData(1,1)
    if xx=x1 then
    reporter.reportevent micpass,"pass","verified"
    else
    reporter.reportevent micFail,"Failed","Not verified"
    end if
    same way you verify for the next two data fields.


  4. #4
    Junior Member
    Join Date
    Apr 2008
    Answers
    3

    Re: How to match data of a table and list box using QTP? Pls answer immidiately.

    Quote Originally Posted by NawabShaikh View Post
    Dim a(<>)

    ''Hold all the to be added Item in the Array/ Use the ListBox Entires at RunTime.

    intCnt = Browser(b).Page(p).Frame(f).WebList(W).getROProperty("items count")

    ''Once u have added the Items Using the Add Functionality (Comparision?)

    For LCnt = 0 to intCnt-1

    '''Hold the Data from the Table
    strTMP = Browser(b).Page(p).Frame(f).WebTable(w).GetCellData(LCnt +1,1)
    ''Assuming that the added data is reflected in the First Column
    if strComp(strTMP,a(LCnt) = 0 then
    Reporter.ReportEvent micPass,"SUCCESS","SUCESS"
    else
    Reporter.ReportEvent micFail,"FAILURE","FAILURE"

    end if

    Next




    Regards,
    Nawab




    Hi Nawab,
    Thanks For ur reply, But this script program is not working for my appliction. Can you simplify it a bit please.

    Warm Regards,
    Sunita


  5. #5
    Junior Member
    Join Date
    Apr 2008
    Answers
    4

    Re: How to match data of a table and list box using QTP? Pls answer immidiately.

    Store the added data in an array

    dim data_added
    data_added=array("x1","x2",x3")
    'verify the data in the listbox
    for i=1 to 3
    data_list=Browser("Listbox").Page("Listbox").Frame("AppWindow").WebTable("Name").GetCellData(1,i)
    if data_list=data_added(i)
    msgbox "pass"
    else
    msgbox "fail"
    end if
    next


  6. #6
    Expert Member
    Join Date
    Jan 2007
    Answers
    211

    Re: How to match data of a table and list box using QTP? Pls answer immidiately.

    Nested Loop is required...

    1.Outer one to traverse for Weblist(Combobox arrays entry)
    2.Inner one to traverse for each of the WebTable row.


    if this doesn't solve the purpose please revert with specs, I will help with the complete code.


    Regards,
    Nawab

    Last edited by NawabShaikh; 04-30-2008 at 05:21 AM.

  7. #7
    Junior Member
    Join Date
    Jan 2009
    Answers
    4

    Re: How to match data of a table and list box using QTP? Pls answer immidiately.

    Quote Originally Posted by amarvreddy20 View Post
    Store the added data in an array

    dim data_added
    data_added=array("x1","x2",x3")
    'verify the data in the listbox
    for i=1 to 3
    data_list=Browser("Listbox").Page("Listbox").Frame("AppWindow").WebTable("Name").GetCellData(1,i)
    if data_list=data_added(i)
    msgbox "pass"
    else
    msgbox "fail"
    end if
    next
    Hi Nawab the above script works well for few items, but if the webtable or weblist contains more items like 100+ then how to modify the script.
    Is it possible to put the items in Excel and compare the web tbale items/weblist items with that excel sheet ?
    If yes can you please help me.
    Thanks


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact