简体   繁体   English

如何使用Java Selenium自动化测试选择多行?

[英]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.

相关问题 如何在 Java 中使用 Selenium 自动化测试登录 Gmail? 现在他们阻止登录测试浏览器驱动程序。 有办法吗? - How to Sign-in Gmail using Selenium automation testing in Java? Now that they block sign in from testing browser driver. Is there a way? 自动化测试框架(硒) - Automation Testing Framework (selenium) 自动化测试时如何在 selenium 中获取运行时输入? - How to take runtime input in selenium while automation testing? 如何等待直到通过C#中的硒自动化测试验证了登录名 - how to wait until login is verified with selenium automation testing in C# 如何在命令终端上使用 Behave 运行多个文件功能自动化测试 - How To Run Multiple File Feature Automation Testing Using Behave On The Command Terminal 使用winium进行自动化测试 - Automation Testing using winium 使用Java和JSON请求进行服务器端自动化测试 - Server side automation testing using Java and JSON requests 多语言网站测试自动化 - Multiple languages of website testing automation 如何解决测试中的Java硒错误? - How to Solve Java selenium error in testing? 黄瓜/自动化测试:如何使用javascript函数处理整体概念? - Cucumber/Automation testing: How to approach the overall concept using javascript functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM