How to find and delete a specific record in table/grid using Selenium
Assume that, a page contains a table of records (created dynamically) with Delete, Edit and View options (for each row/record). Now i want to find a specific record with name/id and delete that record. Is this possible in Selenium?
Help me to resolve t开发者_高级运维his! Thanks in Advance.
Sure, we do this all the time in our tests. You need to write an element locator that finds the row you want and identifies the appropriate button, then just Selenium.Click(...)
on it. The exact locator value will depend on your application, but it will probably be something like xpath=//path/to/table/tr[td[pos() = 1 AND text() = 'My Name']]/td/button[@value='Delete']
. In other words, "the button with the value 'Delete' in the row that has 'My Name' in its first cell in the table".
精彩评论