Logo QF-Test

Finding valuable answers
in the Mailing List Archive.


Free Trial  Download  Buy

Thomas Max, QF-Test training and support

Use the full-text search on our web site to find helpful tips on the mailing list.

Thomas Max, 
Sr. Software Engineer & Trainer, QFS

2017 up to now  | 2016 | 2015 | 2014 | 2013 | 2012 | 2011 | 2010 | 2009 | 2008 | 2007

(older archive entries before 2007 are not shown here, but included in the onsite-search)

Mailing List - Entries of 2014

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] How to nicely iterate all DomNode such as Table Collection

  • Subject: Re: [QF-Test] How to nicely iterate all DomNode such as Table Collection
  • From: Gwenael Plantefeve <gwen0504@?.com>
  • Date: Thu, 27 Feb 2014 15:27:49 +0000 (GMT)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=Wp27L/lCJZlkcXNphohznr7RkRqOb3ESIIdpP4lCrIh8+i8Xh1Vh5p4ULwPa1otvw6s7+X8CRSdqNU86UxDHv+4rCS/U15YEYDRbpkPb6Jd+kgOsewNkJdzr06/0TYw2W/XFDAnEW0EEMGBhrLWkWOwsW5iDBMS3Fmgk1xHiv+s=;

Thanks for your help Martin

May I share Approach# 3 - Class index of Component

- In the component defined to the div element matching "class"="item" -> Set a variable into the "Class Index" structure field (e.g. input "$(myIndex)" into "Class Index" field)  
- Now back in the Test Case node add a "loop node
- in loop Node set "myIndex" variable into the "Iteration counter" field
- within the previous loop node, insert a "Fetch text" node or any "check node" where "Component id" is set to that component defined to the div element matching "class"="item"
- the loop now iterates all div child elements

This approach may required less Jython/Groovy programming for Business testers with less technical skills

NOTE that you could set the "Number Of Iterations" of the loop node via SUT Script.
Something like:
node = rc.getComponent("COMPONENT-ID-OF-DIV-ELEMENT")
children = node.getChildren()
rc.setGlobal("myNumIterationVariable", len(children))

Le Jeudi 27 février 2014 14h09, Gwenael Plantefeve <gwen0504@?.com> a écrit :
Thanks for your help.
Approach works fine, even thought I was expecting to avoid scripting to iterate div elements.

Le Mercredi 26 février 2014 14h30, Martin Moser <martin.moser@?.de> a écrit :
Hi Gwen,

there are several ways for doing this:

1) Approach 1 - Simlpe SUT script:
You can record a click on the DIV element with the class list.
Afterwards you can use a SUT-script (Insert node -> Control structures ->
SUT script) like this:

node = rc.getComponent("COMPONENT-ID-OF-DIV-ELEMENT")
children = node.getChildren()
for child in children:
    if child.getAttribute("class") == "item":
        #asserts on child

2.) Approach 2 - Use CustomResolver and SUT script:
A more elegant approach could be that you tell QF-Test that a web object
with the attribute class="list" should act as list.
Therefore call the procedure "qfs.web.ajax.installCustomWebResolver" from
the standard library qfs.qft.
There you specify the argument "goodClasses" and set "item,list" as value.

Afterwards you record a click at the object with the list again and insert
a SUT-script, but with following code:

node = rc.getComponent("COMPONENT-ID-OF-DIV-ELEMENT")
children = node.getElementsByClassName("item")
for child in children:
    #asserts on child

Best Regards,

--On Dienstag, Februar 25, 2014 10:58:42 +0000 Gwenael Plantefeve
<gwen0504@?.com> wrote:

> Hi,
> In Web testing, I have the following Web page structure:
> ...
> <div class="list">
>     <div class="item">value1</div>
>     <div class="item">value2</div>
>     <div class="item">value3</div>
>     <div class="item">value4</div>
> </div>
> ...
> I would like to iterate all div elements with same class name (here
> class="item"). And do some asserts on value of each div element.
> What is the best way to handle this?
> Thanks in advance for your help
> Gwen

Martin Moser
Development & Support

E: martin.moser@?.de
T: +49 (0)8171 38648-14
F: +49 (0)8171 38648-16

Quality First Software GmbH | www.qfs.de
Tulpenstr. 41 | 82538 Geretsried | Germany
GF Gregor Schmid, Karlheinz Kellerer
HRB München 140833

Videos Downloads Documentation Buy Free Trial