title: Issues in clicking element
body: <p>I am using java selenium for saving web data if any changes made.</p>
  
  <p>Web page contains two buttons 'Confirm' and 'Cancel'. If i made any changes in web page, both 'confirm' and 'cancel' buttons will be visible at the time i can click confirm button by using below code .</p>
  
  <pre><code>WebElement confirm =wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(), 'Confirm')]")));      
  confirm.click();
  </code></pre>
  
  <p>If there is no changes in web page , Confirm button will get disabled(grayed) at the time i want to click Cancel button Automatically.</p>
  
  <p>I have tried with below code ,  it is not working. Please help on this.</p>
  
  <pre><code>try
        {
            WebElement confirm = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(), 'Confirm')]")));
            confirm.click();
        }    
        catch (ElementNotVisibleException exception)
        {
            WebElement cancel = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(), 'Cancel')]")));
  
            cancel.click();
  
        }
  </code></pre>