python 2.7 - How to find the number of elements/tags present under specific tag? -
how find total number of elements/tags present under specific tag ?
<div id="maintag class='maintag'> <div id="submaintag1" class="submaintag1"> <div id="subtag1" class="subtag1"> <div inner tags again> <div inner tags again> <div id="subtag1" class="subtag1"> <div inner tags again> <div inner tags again> <div id="subtag1" class="subtag1"> <div inner tags again> <div inner tags again> <div id="subtag1" class="subtag1"> <div inner tags again> <div inner tags again>
i looking div
tags having id
, class
subtag1
.as per snippet provided above, need count value 4
. verifyxpathcount
not return counts.
storexpathcount | //div[@id='maintag']/div[@id='submaintag1']/div | count echo ${count} storexpathcount | //div[@id='maintag']/div[@id='submaintag1']//div | count echo ${count} storexpathcount | //div[@id='maintag']/div[@id='submaintag1']/* | count echo ${count}
all above returns 0
, nothing returns actual value 4
. not sure, missing here.
selenium ide/web-driver:python , fine.
answer: storexpathcount
working fine. had missed select frame. get matching xpath count
works fine in robot framework.
adding kjhughes's answer, since didn't understand trying achieve using robot framework. wasn't clear, defense.
using xpath provided, use xpath should match x times keyword. this:
xpath should match x times //div[@id='maintag']/* 4
if need store retrieved matching count, can use quite similar keyword, get matching xpath count, this:
${count}= matching xpath count //div[@id='maintag']/*
Comments
Post a Comment