我尝试使用selenium自动化选择多行,如下所示。
this.selectLineInTable(Locator.LOCATOR_LIST, "name", t1.getName()).
this.selectLineInTable(Locator.LOCATOR_LIST,"name",t2.getName()));但它不起作用。有谁能帮我解决这个问题吗?
发布于 2017-05-11 13:25:50
尝试如下所示:
Actions act = new Actions(driver);
act.keyDown(Keys.CONTROL).moveToElement(driver.findElement(By.xpath("first element to select"))).click().build().perform();
act.moveToElement(driver.findElement(By.xpath("second element to select"))).click().release().build().perform();发布于 2017-05-11 16:16:58
Actions act = new Actions(driver);
String m1 = this.selectLineInTable(Constant.LOCATOR_LIST_MOFULL, "name",psv.getName());//1st element
String m2=this.selectLineInTable(Constant.LOCATOR_LIST_MOFULL, "name",psTest.getName());// 2nd element
act.keyDown(Keys.CONTROL).moveToElement(driver.findElement(By.name(m1))).click().build().perform();
act.moveToElement(driver.findElement(By.name(m2))).click().release().build().perform();protected String selectLineInTable(String scLocatorBody,String key,String value)抛出异常{ String scLocatorLine = this.findLineInTable(scLocatorBody,key,value);
if (scLocatorLine == null) {
// No line for key / value
this.logError("The row [" + key + "=" + value + "] does not exist", null);
} else {
// Click on the line
StringBuffer lRow = new StringBuffer();
lRow.append(scLocatorLine).append("col[fieldName=").append(key).append("]/");
this.clickOnElement(lRow.toString());
sleep(500);
}
return scLocatorLine;
}原因:方法:找不到元素:{“org.openqa.selenium.NoSuchElementException”:“name”,"selector":"scLocator=//ListGridID=\"ssr_grid\"/body/row/"}
https://stackoverflow.com/questions/43889068
复制相似问题