Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpage is showing "Can't find variable: Promise" waring on pageres 4.5.0 and phantomjs 2.1.1 #304

Closed
gealbin opened this issue May 19, 2017 · 5 comments

Comments

@gealbin
Copy link

gealbin commented May 19, 2017

Hi,

I'm trying to get a snapshot of a webpage that contains an embedded Power BI report. The snapshot is not showing some components of the page that are shown in other browsers. After checking the warnings, I got some js errors that are not shown in Chrome, the waring are like this:
Warning: ReferenceError: Can't find variable: Promise → http://[...]/powerbi.js on line 5277

It seems to be an issue with phantomjs and ES6 (which I'm not sure if it still present in recent versions of phantomjs). I also read that can it be fixed including some libraries in the code, for example promise-polyfill, but I’m not sure if that will help nor how to include that code in the 'script:' option.
I’m using Nodejs v 6.10.3, phantomjs v 2.1.1 and pageres 4.5.0

Can anybody help me to fix this issue? Thanks in advance!

@kevva
Copy link
Contributor

kevva commented May 19, 2017

You could just specify a path to the file containing your polyfill. E.g (assuming you're using the CLI):

$ pageres --script path/to/file.js example.com 1600x900

@gealbin
Copy link
Author

gealbin commented May 19, 2017

Ok, I'm using this approach, and still the same error. The script is in the same directory. any other ideas?

function getImage(call) {
    const pageres = new Pageres({
            delay: 15,
            filename: fileName,
            script: 'promise.min.js'
        })
        .src(url, ['1366x768'])
        .dest(__dirname)
        .on('warning', function(err) {
            console.log('Warning: ' + err);
        })
        .run()
        .then(function() {
            console.log('End');
            call();
        })

Thanks for your help!

@SamVerschueren
Copy link
Contributor

Try using script: path.join(__dirname, 'promise.min.js')

@gealbin
Copy link
Author

gealbin commented May 22, 2017

Thanks again for your help. After testing different scenarios, and your suggestions, the problem seems to be how phantomjs renders the website.
BTW, is there any way to use pageres with other browser?

@kevva
Copy link
Contributor

kevva commented May 22, 2017

We will be supporting headless Chromium in the future. See kevva/screenshot-stream#40. For now, no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants