I encountered an issue while trying to check all the checkboxes in a windows application
This is my code:
Actions actions = new Actions(driver);
var elements = driver.FindElementByName("Upload Categories").FindElementsByTagName("CheckBox");
foreach (var element in elements)
{
actions.DoubleClick(element).Perform();
}
And I would expect the code to iterate through all the elements and double click on them.
Instead it behaves like there is another loop inside iterating a list of elements made out of the required element and all the elements indexed before it in the initial list.
I don't understand why
LE:
It had something to do with the fact that "actions" is declared outside of the loop
This is the working version:
var elements = driver.FindElementByName("Upload Categories").FindElementsByTagName("CheckBox");
foreach (var element in elements)
{
Actions actions = new Actions(driver);
actions.DoubleClick(element).Perform();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…