How do I access an iframe from CasperJS?

Spent forever looking for this, and of course I found the answer minutes after posting the question. I can use the new frame switching commands added to phantomjs in this commit. Specifically, the this.page.switchToChildFrame(0) and this.page.switchToParentFrame() functions. It appears undocumented, and it also seems that the methods have been changed for upcoming releases, but it … Read more

Why I am not able to render my ReactJS application using PhantomJS 2.1.1?

Probably has to do with the lack of ES6 support in PhantomJS. To check I added page.onError() callback to your script (always handy!) and opened some React example site to get this error: ReferenceError: Can’t find variable: Symbol To polyfill Symbol one can inject a core.js script from this excellent package into the page before … Read more

can phantomjs work with node.js?

phantomjs-node isn’t an official supported npm package for phantomjs. Instead, it implements a “nauseously clever bridge” between node and phantom by creating a web server that uses websockets to serve as an IPC channel between node and phantom. I’m not making this up: So we communicate with PhantomJS by spinning up an instance of ExpressJS, … Read more

How to properly stop phantomjs execution

As of July 2016, driver.close() and driver.quit() weren’t sufficient for me. That killed the node process but not the phantomjs child process it spawned. Following the discussion on this GitHub issue, the single solution that worked for me was to run: import signal driver.service.process.send_signal(signal.SIGTERM) # kill the specific phantomjs child proc driver.quit() # quit the … Read more

Looping over urls to do the same thing

PhantomJS is asynchronous. By calling page.open() multiple times using a loop, you essentially rush the execution of the callback. You’re overwriting the current request before it is finished with a new request which is then again overwritten. You need to execute them one after the other, for example like this: page.open(url, function () { waitFor(function() … Read more

How to render part of a page with PhantomJS?

To only render part of a page you need to set the clipRect attribute for the page and then render it. var clipRect = document.querySelector(selector).getBoundingClientRect(); page.clipRect = { top: clipRect.top, left: clipRect.left, width: clipRect.width, height: clipRect.height }; page.render(‘capture.png’); I don’t understand the second part of your question. Phantom.js is headless meaning that there is no … Read more

techhipbettruvabetnorabahisbahis forumu