1

enter image description here

In screen you can see, that entered selector is only one.

Here is code, where I have entered the same selector, but getting error like this:

Element info: {Using=css selector, value=//*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]}
Find element :By.cssSelector: //*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]
Get Exception: invalid selector: An invalid or illegal selector was specified

Code trils:

private static final By naryste = By.cssSelector("//*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]");
    @Step("Pasirenkame juridinio asmens organizaciją iš reikšmių sąrašo")
    public createOrganization selectMembership() {
        button.click(naryste);
        return this;
    }
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Jetz
  • 207
  • 2
  • 4
  • 14

1 Answers1

1

The locator you have used:

//*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]

is essentially an but not a

You need to change:

By.cssSelector("//*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]");

As:

By.xpath("//*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • thank you for answer. But selenium can't find this xpath: `Find element :By.xpath: //*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')] Find element :By.xpath: //*[contains(@class,'v-label v-label--active theme--light primary--text') and contains(text(),'Narystė')]` – Jetz Nov 08 '21 at 16:19
  • @Jetz That should a different error and a different question all together. Feel free to raise a new question with your new requirement please. – undetected Selenium Nov 08 '21 at 16:21