Find element by attribute

后端 未结 4 1728
鱼传尺愫
鱼传尺愫 2020-11-30 03:37

I am trying to find an element with Attribute. Well, I can find elements with Id, tagName, Xpath and all other predefined methods in Selenium. But, I am trying to write a me

4条回答
  •  被撕碎了的回忆
    2020-11-30 04:28

    I do not understand your requirement:

    Assuming XPath is not an option ...

    If this was just an incorrect assumption on your part, then XPath is the perfect option!

    webDriver.findElements(By.xpath("//element[@attribute='value']"))
    

    Of course you need to replace element, attribute, and value with your actual names. You can also find "any element" by using the wildcard:

    webDriver.findElements(By.xpath("//*[@attribute='value']"))
    

提交回复
热议问题