I have a <ul>
with xpath:position = //ul[5]
which contains some <a>
.
The first <a>
has xpath:position = //ul[5]/li/div/div/a
, the next <a>
has xpath:position = //ul[5]/li[2]/div/div/a
and the next has xpath:position = //ul[5]/li[3]/div/div/a
and goes on...
So, for every new <a>
into this <ul>
the xpath:position
of <a>
get a [#]
after <li>
.
What I need is an example of how I'll count how many <a>
exist into this specific <ul>
and then get the href
attribute of each <a>
into a list.
I have try this:
WebDriver driver = DriverFactory.getWebDriver()
def aCount = driver.findElements(By.xpath("//ul[5]/li/div/div/a")).size()
println aCount
But it counts all the <a>
of the page and not only the ones withing the <ul>
with xpath:position = //ul[5]
!!!