Skip to content
Advertisement

Unable to click a button in Selenium

I’m facing a tough time clicking a button from Selenium.

Here’s the DOM: http://pasteboard.co/GHIjMd6.png

I’ve declared the button WebElement this way using Xpath (a valid Xpath that returns one node as per Firepath):

JavaScript

I’ve tried clicking the said button with send_this_msg_btn Xpath in below mentioned ways, but none of them work for me.

WebDriver’s click() method : send_this_msg_btn.click()

JavaScriptExecutor:

JavaScript

Actions class:

JavaScript

I also checked if the button is inside a frame/iframe, but that’s not the case either.

Advertisement

Answer

Changing the xpath to .//mp-button[@class='mp-button-primary submit_button'] resolved the issue, but I’m not sure if this should be the accepted answer since I’m not sure if it’s a fragile xpath. Any suggestions are welcome!

Advertisement