Micro Focus QTP (UFT) Forums
Problems in For loop - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Problems in For loop (/Thread-Problems-in-For-loop)



Problems in For loop - jyotikrushna - 01-21-2010

Hi Ankur,

I am facing problem in the following scenario.
There are number of links named "remove" present in my application, I declared a descriptive object to find out total no. of links present since it is dynamic. Using For loop I am pointing those links using index value.When I tried to click on those links in script it's working but the alternative nos are going ( means it first clicked on Link1 then link3 then Link5....in this way). But Iwant to click in sequentially like first Link1 then Link2 then Link3...etc. The following is the code that I created:
-------------------------------------------------------------------
Code:
If  browser(obr).page(opg).link(company_edit).exist Then
browser(obr).page(opg).link(company_edit).click
End if
Dim remove_link
Set remove_link=description.Create
remove_link("micclass").value="Link"
remove_link("innerhtml").value="Remove"
remove_link("html id").value=".*companyRemoveBtn.*"
Set rm_link=browser(obr).page(opg).childobjects(remove_link)
cnt=rm_link.count

For i=0 to cnt-1
browser(obr).page(opg).link("html id:=.*companyRemoveBtn.*").click
Next

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

Here the link html ids are like companyRemoveBtn1,companyRemoveBtn2,companyRemoveBtn3 etc...so I have used RE.


Please reply my post asap...in my id jyotikmo@rsgsystems.com orjyoti.krushna@gmail.com

Thanks
Jyotikrushna



RE: Problems in For loop - deepak6532 - 01-21-2010

Hi,
Can you try for this.

For i=0 to cnt-1
rm_link.item(i).click
Next


Regards
Deepak


RE: Problems in For loop - Saket - 01-22-2010

Try

browser(obr).page(opg).link(rm_link(i)).click