Search code examples
javaseleniumselectorselenide

find option by value error: invalid selector: An invalid or illegal selector was specified


I have a simple method that should find selected options in a multiselect and check its' values. Here it is:

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));
}

But .shouldHave(value(cat1) throws an error:

invalid selector: An invalid or illegal selector was specified

All types are right. Parameter of shouldHave() is of Condition class as expected and value() expects string. So what is wrong with that?


Solution

  • The problem was not on the line with options.find() but in the :selected selector above. And as author of Selenide framework wrote it is necessary to allow this type of selectors manualy:

    Configuration.selectorMode = SelectorMode.Sizzle;