Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Itereate through Link Items
#1
Solved: 10 Years, 9 Months ago
Hey guys,

i am new to this board and the whole QTP.

With this code i iterate through links on a website:

Code:
i=0
j=1
While Browser("IDD Portal Login").Page("IDD Portal").Frame("frameLeft").Link("class:=arrow_normal", "html tag:=A", "index:="&i).Exists = true

    Datatable.SetCurrentRow (i+1)
    Browser("IDD Portal Login").Page("IDD Portal").Frame("frameLeft").Link("class:=arrow_normal", "html tag:=A", "index:="&i).Click
    i = i+1
    Wait 2

    While Browser("IDD Portal Login").Page("IDD Portal").Frame("frameMain").Link("class:=arrow_bold", "html tag:=A", "index:="&j).Exists = true

        txt = Browser("IDD Portal Login").Page("IDD Portal").Frame("frameMain").Link("class:=arrow_bold", "html tag:=A", "index:="&j).GetRoProperty("innertext")

        If txt <> "Instanz auswählen" Then
            print txt
            Datatable("Berichtstitel", dtGlobalsheet) = txt
        End If

        j = j+1
        
    Wend
    
Wend
Datatable.ExportSheet "D:\Daten\Berichtsl.xls", 1

As u may know now, the parser dont accept this, because the function EXISTS is not possible to use in that context.

Now i ask you, how i can define an end of my ieration? The count of iteration has to be variable. Anyone has an idea?

thanks in advance, lucster.
Reply
#2
Solved: 10 Years, 9 Months ago
Hi..
The above approach might NOT work as expected when you have only one link in the page. This is because, QTP uses index property only when multiple objects are found. When there is only one object, index property is simply ignored, so the above loop will repeat indefinitely. (even if you set index=10000, QTP's Exists property will return the value as True; but they all refer to same Link here)

So, Take the count first and proceed.

Code:
Set chObj = Description.Create
chObj("micclass").Value= "LINK"
chObj("html tag").Value ="A"
chObj("class").Value ="arrow_normal"

objCount = Browser("IDD Portal Login").Page("IDD Portal").ChildObjects(chObj).count
Reply
#3
Solved: 10 Years, 9 Months ago
This is how it works, your code needed some edit.


Code:
Set chObj1 = Description.Create
[b]'chObj1("micclass").Value= "LINK"[/b]
chObj1("html tag").Value ="A"
chObj1("class").Value ="arrow_normal"

objCount1 = Browser("IDD Portal Login").Page("IDD Portal")[b].Frame("frameLeft")[/b].ChildObjects(chObj1).count
Thanks for your help Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [UFT] [WPF] DataGrid: get items of ControlTemplate robertosalemi 0 3,287 07-14-2016, 07:52 PM
Last Post: robertosalemi
  SwfList: unchecked all items robertosalemi 0 1,843 12-21-2015, 03:46 PM
Last Post: robertosalemi
  Select Menu items shilpaS 1 6,737 06-19-2015, 01:23 AM
Last Post: supputuri
  Object Spy not detecting items in C ICL AndyBSG 5 3,986 11-28-2014, 09:32 PM
Last Post: AndyBSG
  to verify the presence of items in wpf application Priyanka2 0 2,245 10-10-2013, 03:52 PM
Last Post: Priyanka2

Forum Jump:


Users browsing this thread: 1 Guest(s)