I'm trying to count the number of rows within a data grid on a webpage using Selenium. Each row is represented by a div using the following structure (simplified for this post) :-
<div id="resultsGrid">
<div>
<div>
<div/>
<div>
<div class="canvas">
<div data-bind="foreach: renderedRows">
<div>list item</div>
<div>list item</div>
<div>list item</div>
<div>list item</div>
</div>
</div>
</div>
</div>
</div>
</div>
From reading other similar posts I've tried using the following code and XPath to return the number of div's within the <div data-bind="foreach: renderedRows">
var rowCount = webDriver.FindElements(By.XPath("//*[@id='usersResultsGrid']/div/div/div[2]/div/div")).Count;
Whenever I try this I just get a count of 1 returned, not the expected 4 (in this example). Can anyone point in the right direction as to what I am doing wrong?
Thanks.