How do I verify that an element does not exist in Selenium 2

前端 未结 8 1084
误落风尘
误落风尘 2020-12-05 05:29

In Selenium 2 I want to ensure that an element on the page that the driver has loaded does not exist. I\'m including my naive implementation here.

    WebEle         


        
8条回答
  •  遥遥无期
    2020-12-05 05:52

    You can use this:

    Boolean exist = driver.findElements(By.whatever(whatever)).size() == 0;
    

    If it doesn't exist will return true.

提交回复
热议问题