Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97756

How to count the number of attributes whose value is lager than 0 in Selenium Python?

$
0
0

I'm using Selenium Python to count the number of attributes.

The html code is here:

<div id="leftw">
<a class="cat "  cid="1">BEVERAGE</a>
<a class="cat "  cid="8">APPS</a>
<a class="cat "  cid="2">SOUPS</a>
<a class="cat "  cid="9">SALADS</a>
<a class="cat "  cid="3">SANDWICHES</a>
<a class="cat "  cid="10">COMBOS</a>
<a class="cat "  cid="4">ENTREES</a>
<a class="cat "  cid="11">PIZZA</a>
<a class="cat "  cid="5">CALZONE</a>
<a class="cat "  cid="12">STROMBOLI</a>
<a class="cat "  cid="6">PASTRIES</a>
<a class="cat "  cid="13">DESSERTS</a>
<a class="cat "  cid="7">BREAD</a>
<a class="cat "  cid="14">SIDES</a>
<a class="cat "  cid="15">MEAT BY POUND</a>
<a class="cat "  cid="18">Kids Meal</a>
<a class="cat "  cid="19">MISC</a>
<a class="cat "  cid="0"></a>
</div>

I want to count the a tag number whose cidvalue is not equal to 0.Because there is no value in a tag whose cid value equal 0.

if I run:

count_category = len(driver.find_elements_by_css_selector("#leftw .cat"))

I can only get the total number of all a tags. But I want to exclude the a tag whose cid value equals 0.


Viewing all articles
Browse latest Browse all 97756

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>