I have a problem creating a list
with attributes follows HTML code:
<div class="post clearfix" data-post-id="92842173">...</div>
<div class="post clearfix" data-post-id="92841636">...</div>
<div class="post clearfix" data-post-id="92618462">...</div>
<div class="post clearfix" data-post-id="90658834">...</div>
Current C # code:
var valor = chromeDriver.FindElement(By.XPath("//div[contains(@class, 'post')]")).GetAttribute("data-post-id");
So I only get the first data-post-id="92842173"
.
I would like to create a list with all data-post-id
. I have tried to do it as follows, but it gives an error.
List <IWebElement> list1 = chromeDriver.FindElement(By.XPath("//div[contains(@class, 'post')]")).GetAttribute("data-post-id");