Does Linq generate this ID? How to recover?

Asked

Viewed 51 times

0

I’m doing an automation using Selenium Webdriver and I’m taking all the elements of a Table.

I used the code below:

var qntd= driver.FindElements(By.XPath("//*[@id='dataTable']/tbody/tr")).Skip(3);

Then I realized that each element generated an Id that is not from the Html Id attribute

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

I tried to recover this id with a query but could not, because the return is the HTML Attribute Id

var query = from a in qntd
                    select a.GetAttribute("Id");

Where does this ID come from and how to retrieve it?

  • Do you want to return an element by id? If yes maybe this code can help you driver.Findelement(By.Id("ID"));

1 answer

0

Unfortunately you will not be able to access this field because the "Findelements" method returns the elements in the form of Iwebelement. Iwebelement does not have a method implemented to get the ID value you were looking for.

If the Findelements method was to return the Remotewebelement type, or even Chromewebelement, we could access this field because Remotewebelement has a method to access it. However, this method is not implemented in the interface. Therefore, there is no way to achieve this. So I’m not seeing a way to get this ID.

See the Remotewebelement.Cs source code for more information:

https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/webdriver/Remote/RemoteWebElement.cs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.