Closed appzone closed 7 years ago
Why? What are you trying to do? For a page load, you can just repond to DOMContentLoaded
in the browser.
i am trying to do page automation. like this url http://phantomjs.org/page-automation.html
i am trying to achieve something like this
describe("Checkout from merchant", function() {
it("Should return application ID", function(){
==> do some phantomJS page automation
});
});
is it possible ?
my code is
describe("Checkout from merchant", function() {
it("Should return application ID", function(){
page.open('http://www.httpuseragent.org', function(status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var ua = page.evaluate(function() {
return document.getElementById('myagent').textContent;
});
console.log(ua);
}
phantom.exit();
});
});
});
but i got this error page is not defined
in the phantomJs example i must declare the page with
var page = require('webpage').create();
if i put that, i get following error
Uncaught ReferenceError: require is not defined
at page_one.js:1
btw i find another solution. separate between mocha and phantomjs instance
but i just want to know if is it possible to do like my comment description upper.
thanks
This is not the project you want. It is not for externally automating page crawls - it is for extracting mocha test results on a single page. Please use mocha-casperjs or (Nightmare.js)[https://github.com/segmentio/nightmare]. I'd recommend the later as it uses the more modern Electron, as phantomjs is far behind, based on QT5 and without maintainers.
Hi, how can i call phantomJS function with mocha-phantomJs ?
let say i want to call page.open(url, function (status) { //Page is loaded! phantom.exit(); });
how i do that in mocha-phantomjs ? i read there is a callPhantom(), but how i use that ? thanks