In my quest to develop integration tests using Selenium with JavaScript bindings, WebdriverJS, Mocha, and Chai, I stumbled across an interesting suggestion in this article. It proposed using WebdriverJS
over the official SeleniumJS bindings for some reason.
My goal is to create a simple script that navigates to our homepage and clicks on the link that leads to the About
page. The HTML structure of the link is:
<ul id="nav">
...
<li>
<a href="/about/">
<span>About</span>
</a>
</li>
...
</ul>
Below is the code I wrote to click on this link:
client
.url(my_url)
.getTitle (err, title) ->
expect(err).to.be.null
.click 'a[href*="about"]', (err) ->
expect(err).to.be.null
Unfortunately, the last line always throws an error. I suspect it might have to do with the nested CSS selectors. Strangely though, when I attempt to access this element using jQuery
in the browser, I do retrieve the object with the same line of code.
Any insights on what the issue might be here?
Personal Note: The documentation for WebdriverJS
seems lacking, with the .click()
function having minimal explanation.