I am trying to count the rows of the table and below is the HTML: my html
I want to get the total count rows of the table, discarding table header and expanded row. I had tried the code below:
var altrowCount = driver.FindElement(By.Id("resultsRepeaterGrid")).FindElements(By.TagName("tr")).Count;
Now I realized it is counting all the tr. Hoping to get some input from who had experienced this. Thanks!
I had a working protractor script which was
searchResCount = element.all(by.css('#resultsRepeaterGrid tr[class="row"], tr[class="altrow"]'));
Now how do I translate this syntax to c# webdriver language?
1 Answer 1
To translate your protractor script use the same css selector:
int searchResCount = driver.findElements(By.CssSelector("#resultsRepeaterGrid tr[class="row"], tr[class="altrow"]")).Count;
-
what happened was, it counted all tr that can be found in the HTML. What I wanted is to only count the occurrences of the classes 'altrow' and 'row' and maybe add them up. I had a working protractor script which is this: searchResCount = element.all(by.css('#resultsRepeaterGrid tr[class="row"], tr[class="altrow"]')); I am not sure how to translate to C# webdriver languageMarj– Marj2016年06月17日 13:09:30 +00:00Commented Jun 17, 2016 at 13:09
-
1I'm not sure what is your goal, but if you have working protractor script it should be easy to change it to C# webdriver. Try with the same css selector:
driver.findElements(By.CssSelector("#resultsRepeaterGrid tr[class="row"], tr[class="altrow"]")).Count
kotoj– kotoj2016年06月17日 14:30:42 +00:00Commented Jun 17, 2016 at 14:30