Appium:如何编写for循环来点击带索引的按钮?

Appium: How to write for-loop to click through buttons with index?

我正在使用 C# 和 Appium 为我的公司自动化 Windows 10 软件。在书签栏上,有一个我想要点击的选项卡列表。它们是索引为 15-20 的按钮。而不是做

driver.FindElementsByXpath("//Pane/Button[15]").Click();

driver.FindElementsByXpath("//Pane/Button[16]").Click();

driver.FindElementsByXpath("//Pane/Button[17]").Click();

driver.FindElementsByXpath("//Pane/Button[18]").Click();

driver.FindElementsByXpath("//Pane/Button[19]").Click();

等等,怎么写一个for循环,会循环点击onbutton[15]button[30]? Appium甚至可以做到这一点吗?谢谢!

我明白了。我应该将 WindowsElement 行放在 for 循环中。可能不是最佳解决方案,但它可以满足我的要求。感谢大家。也感谢@Selvin 的烤肉。

for(int i=15; i<=30; i++)
        {
            WindowsElement buttons = FBsession.FindElementsByXPath("//Pane/Button")[i];
            buttons.Click();
        }