0

Need one more help on below to click() on Ask me later button.

<div align="center" class="mar-b0">
  <button class="custom-green md-button md-ink-ripple no-margin md-button"
          type="button" ng-transclude="" ng-click="vm.goHome();">
     <span class="ng-binding ng-scope">Ask me later</span>
  </button>
</div> 

I have tried with below code -

new WebDriverWait(driver, 20)
.until(ExpectedConditions.elementToBeClickable(
     By.xpath("//span[@class='ng-binding ng-scope' and contains(.,
              'ASK ME LATER')]"))).click();
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Priya
  • 13
  • 5

1 Answers1

0

The element is Angular element so to click() on the element you have to induce WebDriverWait for the element to be clickable and you can use either of the following Locator Strategies:

  • Using cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.custom-green.md-button.md-ink-ripple.no-margin.md-button[ng-click*='goHome']>span.ng-binding.ng-scope"))).click();
    
  • Using xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='custom-green md-button md-ink-ripple no-margin md-button' and contains(@ng-click, 'goHome')]/span[@class='ng-binding ng-scope' and text()='Ask me later']"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352