mercredi 3 mars 2021

Is there a way in Selenium C# to find a specific update button on a table if all the ids are the same?

I am writing a selenium test to test a crud application where you can add, update, or delete a user. I have a table that dynamically displays all of the fields. When I add a new user, a new edit button is also added and when clicked edits that particular user. When trying to test this with selenium, I am not sure how to edit a specific user. I would like to edit the 4th user in the list, which would be index 3. I tried this,

var edit = wait.Until((d) => d.FindElements(By.Id("edit")));
edit[3].Click();

but get an index out of range error. If I do this:

var edit = wait.Until((d) => d.FindElement(By.Id("edit")));
edit.Click();

It allows me to edit the first person in the table.

Aucun commentaire:

Enregistrer un commentaire