How can I count the elements in the DOM element using nUnit, Selenium?

Podpryadok Igor
<div id="selected">
      <ul>
        <li>29</li>
        <li>16</li>
        <li>5</li>
        <li>8</li>
        <li>10</li>
        <li>7</li>
      </ul>
    </div>

I want to count the total number of "li" elements in "ul". How is that possible using nUnit, Selenium?

Dazed

First of all, welcome to SO. KunduK is correct though. When you ask questions, please let everyone know what you have attempted and or researched to try and find the answer and what you are stuck with. Questions like this have been asked many times on here.

You can get a count on these elements by using FindElements.

var count = Driver.FindElements(By.XPath("//div[@id='selected']//li")).Count();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I identify every element in the DOM and the order of elements?

How can we find count of element using selenium web driver

How can I located element in selenium using the following element?

How to automate shadow DOM elements using selenium?

How can I count text lines inside an DOM element? Can I?

How can I remove an element that is NOT on the DOM using jQuery?

How can I find all elements in a webpage using selenium python

How can I find elements that are not in the page source using selenium (python)

How can I count HTML elements on a printed page using CSS?

Javascript: How can I count the number of lines of a text element inside a DOM element such as <li>

How can I replace one element with list of elements using jsoup?

How can I hide any DOM element

How I can access DOM element by selector

how can i change dom element with component

How can I count all possible subdocument elements for a given top element in Mongo?

How can I count the number of elements in an array?

How can I receive count of elements?

How can I count the number of elements in IEnumerator?

How can I count elements in a list by type?

How to select an element when either of the elements can be found using Selenium and Java

How can I target a child element within a parent element using selenium in python?

How to automate/access nested shadow DOM elements using selenium python?

How can I assign element count to the variable?

How can I publish NUnit test results using Jenkins Pipeline?

how can I overcome an element or elements for not applying the conditions of loop or skip an element using python?

How to check whether an element on the DOM is in the foreground in Selenium using Java?

How can I update multiple DOM elements using Asp.Net MVC Ajax's UpdateTargetId

How can I access existing dom elements when using react render?

Using Angular and Ionic, how can I add elements to the DOM on a button click