Java的selenium代碼隨筆(7)

//判斷元素是否存在public boolean IsElementPresent (WebElement webElement, By by) {    boolean status = false;    try {        if (webElement == null) {            driver.findElement(by);            status = true;        }else {            webElement.findElement(by);            status = true;        }    } catch (NoSuchElementException e) {        status = false;    }    return status;}//判斷標籤是否存在public boolean IsTagNamePresent (WebElement webElement, String tagName) {    boolean status = false;   if (!webElement.getAttribute(tagName).equals("")){       status=true;   }else {       status=false;   }    return status;}
相關文章
相關標籤/搜索