根据的文档将返回类型。因此,您可以像这样简化代码:Selenium
FindElements(By.XPath("//*[@id="button"]")) List
ReadOnlyCollection<IWebElement>
ChromeDriver chrome = new ChromeDriver();List<IWebElement> textfields = new List<IWebElement>();chrome.Navigate().GoToUrl("https://www.youtube.com/watch?v=9bZkp7q19f0");textfields = chrome.FindElements(By.XPath("//*[@id='button']"));foreach (IWebElement field in textfields){ string my_text = field.GetAttribute("any_attribute_button_tag"); Console.WriteLine(my_text);}


