Error : Element should have been “select” but was “a”

前端 未结 2 1958
天涯浪人
天涯浪人 2021-01-22 06:22

When i am trying to select an option from dropdown list i am getting the error \"Element should have been \"select\" but was \"a\" \" Below is my source code :

         


        
相关标签:
2条回答
  • 2021-01-22 06:46

    That's because this element is not <select> but <a> :)

    When you find element with findElement(By.id("m1tlm0")); click on it. I assume that then list of options will appear. Then select one with By.linkText or By.xpath and click() on it.

    0 讨论(0)
  • 2021-01-22 06:58

    The Select class only works with <select> tags that contain <option> tags. If you have any other tag, it doesn't matter if it behaves like a <select> would, it will be rejected.

    The error is telling you this. You are giving it an <a> tag.

    0 讨论(0)
提交回复
热议问题