[英]How to select multiple rows in a UI grid without holding CTRL key using C#?
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). 我有一个用Angular编写的表,当我编写下面的代码时,我无法单击以选择多行(它适用于下面的表示例)。 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?
我的问题是如何选择UI网格表中的所有行?
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. 我尝试编写一个循环以单击直到到达最后一行,但是对于正在工作的Angular站点,它一次只能选择一行。 I can't use the CTRL key as it needs to run without user interaction.
我不能使用CTRL键,因为它需要在没有用户交互的情况下运行。 I've looked into the Actions class for selenium but I can't get it to work.
我已经研究了硒类的Actions类,但无法正常使用。
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(); actions.KeyDown(Keys.Control).Click(gridTotal [1])。KeyUp(Keys.Control).Build()。Perform();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.