Is it possible to use 'fs' (filesystem) module inside page executed by PhantomJS?
Asked Answered
S

0

0

I want to have access to filesystem on a page that is rendering by PhantomJS headless browser.

I catch an error when JS code is trying to interact with filesystem

var fs = require('fs');
...
ReferenceError: Can't find variable: require

Is there some hack/plugin to PhantomJS that allows to do that?

P.S. I'm using headless tests runner based on PhantomJS (teaspoon) and I want to store some data from tests on filesystem.

Sammysamoan answered 11/6, 2015 at 11:47 Comment(3)
I have no idea how teaspoon works, but I doubt that it has access to the PhantomJS context. The most probable answer is no.Dimerous
My hope is based on fact that PhantomJS isn't browser for users, but for testing. So may be there are some opportunities to extend it functionality in a way traditional browsers aren't extendable to.Sammysamoan
Sure, PhantomJS is extensible and it can do this sort of thing. It's a limitation of the tools that build on top of it.Dimerous

© 2022 - 2024 — McMap. All rights reserved.