So it turns out that the querySelectorAll method does not actually support XPath. This is actually not casperjs at all and is supported by the browser, so it accepts CSS3 selectors, not XPath. It was difficult for me to understand this, so I thought that I would put it in case someone else ran into this problem. You must use the CSS3 selector for this in casperjs, so the line:
var links = document.querySelectorAll(x('//*[@id="horizontalList"]/li[@class="paddingRight6"]/a');
Required to change to:
var links = document.querySelectorAll('ul#horizontalList li.paddingRight6 a');
Happy hack
source share