Selenium webdriver 获取错误元素应该是;选择";但是是",;分区;

Selenium webdriver 获取错误元素应该是;选择";但是是",;分区;,selenium-webdriver,Selenium Webdriver,我有listwebelement&我需要选择所有listwebelement,而不是下拉列表,在框架和窗格中选择它的元素列表 list_xpath = By.xpath(".//div[@class='Class1')]/div[@class='Class2']"); List<WebElement> list = sync on list_xpath Count = List.size(); WebElement tempWebElement; for (int i = 0 ;

我有listwebelement&我需要选择所有listwebelement,而不是下拉列表,在框架和窗格中选择它的元素列表

list_xpath = By.xpath(".//div[@class='Class1')]/div[@class='Class2']");
List<WebElement> list = sync on list_xpath 
Count = List.size();
WebElement tempWebElement;
for (int i = 0 ; i <= Count; i++ )

        {
            tempWebElement = list .get(i);
            reporterHelper.log("selectMultiple Starting ...");
            Select select = new Select(tempWebElement);
list_xpath=By.xpath(“.//div[@class='Class1')]/div[@class='Class2']”);
列表=列表上的同步\u xpath
Count=List.size();
WebElement tempWebElement;

对于(int i=0;i如果您试图传递给Select对象的元素不是“Select”元素,那么它将抛出一个意外的TagNameException。在您概述的情况下,您肯定在尝试使用“div”:

“//div[@class='Class1')]/div[@class='Class2']

因此,您不能使用Select进行此操作。您可能能够构建一组元素,以便在所有元素上按住Ctrl键并单击或按住Shift键并单击。这实际上取决于你想做什么以及网页的行为