自动建议列表:java.lang.IllegalArgumentException:当XPath表达式为null时找不到元素

时间:2017-12-15 05:55:16

标签: java xpath selenium-webdriver

autosuggestionselect(By.xpath(
 Configurations.getSalesLocator("//ul/li/a[text()='"+InvestigationNo+"']")));


public void autosuggestionselect(By by) throws InterruptedException {
    List <WebElement> Elements = driver.findElements(by); 
    System.out.println(Elements.size());        

    for (WebElement element : Elements) {
        System.out.println(element.getText());
        String actual = InvestigationNo;
        String expected = element.getText();
        Thread.sleep(5000);
        if (actual.equals(expected)) {
            element.click();
            break;
        }
    }
}

当我尝试从自动建议列表中选择项目时会发生这种情况。请帮忙。

0 个答案:

没有答案