vendredi 8 janvier 2021

Loop behaving like nested loops when iterating through ReadOnlyCollection

I encountered an issue while trying to check all the checkboxes in a windows application

this is my code:

Actions actions = new Actions(driver);

ReadOnlyCollection<AppiumWebElement> 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

Aucun commentaire:

Enregistrer un commentaire