Uncaught DOMException: Failed to execute '$' on 'CommandLineAPI': not a valid selector

后端 未结 1 808
遇见更好的自我
遇见更好的自我 2021-01-18 18:42

I am writing automation UI tests for my web page using selenium. I have an element on the web page which I am testing:

<< input type=\"checkbox\" id         


        
相关标签:
1条回答
  • 2021-01-18 19:02

    This error message...

    Failed to execute '$' on 'CommandLineAPI': '#screening_questions[0].multiple_choice[0]-dealbreakerField' is not a valid selector.
    

    ...implies that the Locator Strategy you have adapted is not a valid selector.

    As per the HTML you have shared the desired element is a <input> tag with type attribute as checkbox and to use the id attribute you have to escape the . characters and you can use either of the following options :

    • cssSelector :

      "input[id=\"screening_questions[0].multiple_choice[0]-dealbreakerField\"][type='checkbox']"
      
    • xpath :

      "//input[@id=\"screening_questions[0].multiple_choice[0]-dealbreakerField\"][@type='checkbox']"
      
    0 讨论(0)
提交回复
热议问题