0

I am trying to click on the button using selenium on my ionic cordova application. I tried click(), javascript, tap but nothing work.

Can anyone please take a look and suggest. I have attached the screenshot.enter image description here

Error coming when tried with span.

enter image description here

Alex
  • 93
  • 6

1 Answers1

1

As you have highlighted it may be a bit difficult to click on the <button> tag. Hence you can try to click on the inner <span> tag as follows:

WebElement ele = driver.findElement(By.xpath("//button[@class='btn-done disable-hover bar-button bar-button-md bar-button-default bar-button-default-md']/span[@class='button-inner']"));
ele.click();

Update:

Now as you are seeing a WebDriverException: Element is not clickable at point (--, --). It can happen for a number of reasons as discussed in this Discussion. So we will use the JavascriptExecutor click as follows:

WebElement ele = driver.findElement(By.xpath("//button[@class='btn-done disable-hover bar-button bar-button-md bar-button-default bar-button-default-md']/span[@class='button-inner']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", ele);
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Yes tried with span and with the locator you shared but it's not working. Is that because of an ionic button? Any resolution for that. – Alex Aug 22 '17 at 14:46
  • Can you update the question with the exact error stack trace? – undetected Selenium Aug 22 '17 at 14:47
  • Hey Debanjan, I have updated the error when trying to click on the span locator in the problem. – Alex Aug 22 '17 at 15:02
  • @Alex Check my updated Answer and let me know the status. – undetected Selenium Aug 22 '17 at 15:18
  • No, I am not able to click through javascriptExecutor. Tried with both css and xpath. Looks like this is a problem of ion-card or ion-buttons (see the dom of html in the screenshot of the problem). Even with javascriptExcecutor no error is coming and I am able to get the text. – Alex Aug 22 '17 at 15:55
  • Please bump up `Selenium` to v3.5.0, `chromedriver` to 2.31 and `Chrome` to 60.x you will be through. – undetected Selenium Aug 22 '17 at 15:58