如何用新值更新文本框并使用 selenium 网络驱动程序检查计数

How to update text box with new values and check the count using selenium web driver

我遇到了这个问题,我必须计算文本框字段中的值数量是否超过 5 个。如果没有,我可以输入值,如果是,那么我不能再输入了。附上屏幕截图和html。如有任何帮助,我们将不胜感激。

您输入框中的 "keywords" 存储为 span,名称为 class "tag label label-info"。您可以简单地获取该元素的计数并验证它是否为 5:

JAVA -

List <WebElements> tags_list = driver.findElements(By.xpath("//div[@class = 'bootstrap-tagsinput']/span[@class = 'tag label label-info']"));

if(tags_list.size() >= 5)
{
// do whatever you want
}