Mahbub Rahman Mahbub Rahman - 1 year ago 115
Groovy Question

Spock: Select visible elements

I have the html in my Page:

enter image description here

I have the content defined as:

child_criteria(wait: true) { $("div",class:"childSelectInIndex").find("ul",class:"oldSelectIndex") }

trying to select only the number of visible element those do not have

with :

def displayedchild_count = child_criteria.find("li",class:"targetChildAgeForm").not("li",class:"targetChildAgeForm",style:"display:none;").size()

println displayedchild_count
always show the size as 4.

How I can select the size of visible elements?

Answer Source

You should be able to do:

def visibleLis = $("div.childSelectInIndex ul.oldSelectIndex li.targetChildAgeForm")
                      .findAll { it.displayed }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download