No Comments

webdriverIO tips: element wrapped in div is not clickable

Have you run into an error saying "Element is not clickable at point" when you're trying to click a button? You might be seeing this if you have a spinner that appears on your buttons or its a customized button (like a div as a button with inner styled elements). In these cases, you're kinda out of luck if you want selenium to be able to do it because it can't see the element that you want to click on. However... you can hack around it. While selenium isn't able to click the button obscured by another element, the browser can still do it and selenium can inject javascript to run inside the browser. Check out this example:

var runInBrowser = function(argument) { 
var elementToClickOn = browser.$(selector)
> browser.execute(runInBrowser, elementToClickOn);

.execute to the rescue here. You can inject a snippet into the page, so as long as the browser can do it, you can get past the "Element is not clickable" error. This is a hack though and you should only use it sparingly when you need it, $(element).click() should still work the majority of the time. Check out this Stack Overflow discussion here if you're in this situation

Last week, I started working on integrating a test suite previously built using Nightwatch, and making it work with webdriverIO. While I love all of webdriverIO’s features like synchronous code when using their test runner and a REPL, there were a few things that I’d like to share which were a little hard to find in the docs or on a quick search.

In case you missed it... Each day this week, I've been posting one thing I've learned while setting up webdriverIO. Check out my previous posts here:

Sometimes, tutorials and walkthroughs like this can be hard to follow, and things just won't click unless you see it in action. I'm putting together a live-coding video series called Works on my Machine where you can watch me go through a tutorial and see all the mistakes I make along the way. Sign up to my mailing list to get notified when it goes live!

You might also like

More Similar Posts

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.