【问题标题】:find option by value error: invalid selector: An invalid or illegal selector was specified按值查找选项错误:无效选择器:指定了无效或非法的选择器
【发布时间】:2021-03-15 15:03:27
【问题描述】:

我有一个简单的方法,它应该在多选中找到选定的选项并检查其值。这里是:

public void checkArticleCategories(String cat1, String cat2)
{
    ElementsCollection options = $(byName("categories[]")).findAll(":selected");

    options.find(value(cat1)).shouldHave(value(cat1), ofSeconds(14));
    options.find(value(cat2)).shouldHave(value(cat2), ofSeconds(14));
}

但是.shouldHave(value(cat1) 抛出错误:

无效的选择器:指定了无效或非法的选择器

所有类型都是正确的。 shouldHave() 的参数是 Condition 类如预期和 value() 预期字符串。那么这有什么问题呢?

【问题讨论】:

    标签: java selenium selector selenide


    【解决方案1】:

    问题不在于 options.find() ,而在于上面的 :selected 选择器。正如 Selenide 框架的作者所写,有必要手动允许这种类型的选择器:

    Configuration.selectorMode = SelectorMode.Sizzle;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-11
      • 1970-01-01
      • 2023-03-28
      • 2019-06-17
      • 1970-01-01
      • 1970-01-01
      • 2015-06-18
      • 1970-01-01
      相关资源
      最近更新 更多