在我的网页中有多个dropdowns具有相同属性值的
我把所有这些都Webelements放在一个列表中
现在WebElement使用索引从列表中获取一个
在尝试将其输入WebElement到 Select 时,出现错误:
“java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebElement 不能转换为 org.openqa.selenium.support.ui.Select”
请帮忙!下面是我的代码。
int index;
String sIndex = null;
By element = ORUtils.ORGenerator(pageName,objectName);
//Getting all the webelements with same name in myElement List
java.util.List<WebElement> myElements=WebUtils.driver.findElements(element);
//Get index of element on page
Pattern pIndex=Pattern.compile("(.*)");
Matcher mIndex=pIndex.matcher(objectName);
if(mIndex.find())
{
sIndex=objectName.replaceAll("[a-z]","");
sIndex=sIndex.replaceAll("[A-Z]","");
}
index=Integer.valueOf(sIndex);
index=index-1;
//Getting element from the List using index
WebElement myElement=myElements.get(index);
//Type casting WebElement to Select this is where i get the error**
Select …Run Code Online (Sandbox Code Playgroud)