Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 验证web元素中是否存在属性标题_Selenium_Selenium Webdriver - Fatal编程技术网

Selenium 验证web元素中是否存在属性标题

Selenium 验证web元素中是否存在属性标题,selenium,selenium-webdriver,Selenium,Selenium Webdriver,我有一个关于web元素列表的问题。 我有一个方法来验证web元素列表中是否存在文本。 我需要修改它以支持属性title,并验证值是否存在。 他们的方法是否可以更改此方法以支持属性标题 我的方法: public Boolean isStringInWebElementsAttributeList(String expectedValue,List<WebElement> dropdownOptions) throws Exception { Boolean isExi

我有一个关于web元素列表的问题。 我有一个方法来验证web元素列表中是否存在文本。 我需要修改它以支持属性title,并验证值是否存在。 他们的方法是否可以更改此方法以支持属性标题

我的方法:

public Boolean isStringInWebElementsAttributeList(String expectedValue,List<WebElement> dropdownOptions) throws Exception {
        Boolean  isExists = dropdownOptions.stream().map(WebElement::getText).anyMatch(text -> expectedValue.equals(text));
        return isExists;
    }
public Boolean isStringInWebElementsAttributeList(字符串expectedValue,列表下拉选项)引发异常{
布尔isExists=dropdownOptions.stream().map(WebElement::getText).anyMatch(text->expectedValue.equals(text));
回归现实;
}

而不是映射
getText
映射元素的
title
属性

public Boolean isStringInWebElementsAttributeList(String expectedValue,List<WebElement> dropdownOptions) throws Exception {
        Boolean  isExists = dropdownOptions.stream()
                            .map(el->el.getAttribute("title"))
                            .anyMatch(text -> expectedValue.equals(text));
        return isExists;
    }
public Boolean isStringInWebElementsAttributeList(字符串expectedValue,列表下拉选项)引发异常{
布尔isExists=dropdownOptions.stream()
.map(el->el.getAttribute(“标题”))
.anyMatch(text->expectedValue.equals(text));
回归现实;
}