I have a table written in Angular and when I write the code below, I can't click to select multiple rows (it works for the table example below). For my table at work, it only allows me to select one row at a time so looping is not working. My question is how to select all rows in a UI grid table?
I've tried writing a loop to click until the last row is reached, but for the Angular site at work, it only allows one row to be selected at a time. I can't use the CTRL key as it needs to run without user interaction. I've looked into the Actions class for selenium but I can't get it to work.
class Program
{
static void Main(string[] args)
{
IWebElement tableElement;
String _address = "https://datatables.net/examples/api/select_row.html";
IWebDriver _driver = new ChromeDriver();
_driver.Navigate().GoToUrl(_address);
tableElement = _driver.FindElement(By.Id("example"));
Actions actions = new Actions(_driver);
var noRows = _driver.FindElements(By.XPath("//table[@id='example']/tbody/tr"));
for (int i = 0; i < noRows.Count; i++)
{
noRows[i].Click();
}
Console.Write("ALl lines seleected");
}
}
}
I worked it out by adding this line
actions.KeyDown(Keys.Control).Click(gridTotal[1]).KeyUp(Keys.Control).Build().Perform();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.