[英]How to select multiple lines using java Selenium automation testing?
I tried to select multiple lines using selenium automation like below. 我试图使用硒自动化选择多条线,如下所示。
this.selectLineInTable(Locator.LOCATOR_LIST, "name", t1.getName()).
this.selectLineInTable(Locator.LOCATOR_LIST,"name",t2.getName()));
but its not working. 但它不起作用。 Can anyone help me how to solve this issue?
谁能帮我解决这个问题?
try something like below: 尝试类似以下内容:
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();
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) throws Exception { String scLocatorLine = this.findLineInTable(scLocatorBody, key, value); 受保护的字符串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;
}
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"name","selector":"scLocator=//ListGrid[ID=\\"ssr_grid\\"]/body/row[0]/"} 由以下原因引起:org.openqa.selenium.NoSuchElementException:无法找到元素:{“方法”:“名称”,“选择器”:“ scLocator = // ListGrid [ID = \\“ ssr_grid \\”] / body / row [0 ] /“}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.