isElementPresent in selenium 2.0

前端 未结 6 1421
太阳男子
太阳男子 2021-02-19 11:09

Hello all I am using webdriver so if I want to use selenium;s rc function isElementPresent I have to emulate selenium rc so I do something like this:

import org.         


        
6条回答
  •  悲哀的现实
    2021-02-19 11:37

    You can implement it yourself using pure webdriver:

    private boolean isElementPresent(By by) {
        try {
            driver.findElement(by);
            return true;
        } catch (NoSuchElementException e) {
            return false;
        }
    }
    

提交回复
热议问题