![](/img/trans.png)
[英]The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
[英]unable to use sendKeys“sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)”
我正在尝试在sendKeys方法[type WebElement]中发送“ String”作为参数,但是系统将其用作char序列,所以我没有得到正确的输出。
public static void setGridDropDownValue(Selenium selenium, WebDriver webDriver, String strGridId, int nRowIndex, int nCellIndex, String strValue)
{
String strXPath = "//div[@id='"+strGridId+"']//table/tbody/tr[2]/td/div/div/table/tbody/tr["+(nRowIndex+2)+"]/td["+(nCellIndex+1)+"]/";
selenium.click(strXPath);
selenium.doubleClick(strXPath);
strXPath = "//select";
Select selStatus = new Select(webDriver.findElement(By.xpath(strXPath)));
List<WebElement> we = selStatus.getOptions();
for(int i = 0; i< we.size();i++)
{
WebElement wei = we.get(i);
System.out.println("Options : "+wei.getText().toString());
if(wei.getText().toString().equals(strValue))
{
wei.sendKeys(strValue);
break;
}
}
}
例如:我的下拉菜单有4个选项(部分,完成,已验证,删除)。 如果选择的值是“ Partial”,并且我正在发送密钥“ Done”,则它工作正常,但是如果选择的值是“ Verified”,并且正在发送“ Done”,则系统选择了“ Delete”。 我没有得到它的工作程序,但是我认为系统正在比较字符。 如果选择的值为“已验证”,而我正在发送“部分”,则系统选择“部分”(工作正常)。
仅供参考:在用户双击该元素之前,我的下拉菜单不可见。
请让我知道是否可以使用sendKeys方法发送“字符串”。 TIA
再次设置JRE系统库。 如果您使用eclipse,请执行以下步骤:
除了编辑,您还可以通过删除和添加来完成。 这些步骤是:
您可以使用Select类
Select select = (Select) driver.findElement(By.xpath(strXPath));
select.selectByVisibleText(strValue);
如果您使用的是eclipse,请执行以下步骤:-1.右键单击您的项目->构建路径->配置构建路径2.选择Java编译器->更改为1.7的级别3.单击应用->确定。
我认为这应该有效。 没有编译错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.