How to select value from the webpage using PhantomJS? Here is code in html:
<html lang="en-US" class="xxx">
<head></head>
<body class="xxxx">
<section class="Section">
<div id="mocha">
<ul id="mocha-stats">
<li class="passes">
<a href="">passes:</a>
<em>443</em>
</li>
<li class="failures">
<a href="">failures:</a>
<em>4</em>
</li>
</ul>
</div>
</section>
</body>
</html>
I want to select value from the passes which is 443. Here is my code, but it returns null.
var page = require('webpage').create();
var url = 'http://localhost:9001/';
page.open(url, function (status) {
if (status === 'success') {
var input = page.evaluate(function() {
return document.querySelectorAll("li.passes").value;
}, 2000);
console.log(input);
phantom.exit();
}
});