Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

page.render() not working as expected when navigating to pages once logged into site #14647

Closed
sramzan opened this issue Nov 16, 2016 · 5 comments
Labels

Comments

@sramzan
Copy link

sramzan commented Nov 16, 2016

Phantomjs Version: 2.1.1
OS: Mac OS El Capitan
Installed Phantom via npm

Steps to reproduce the problem:

  • I do highly doubt this is an issue with our site alone, but if you were to:
    1. Login to site (I used a proxy which is necessary along with --ssl-protocol=any, --ignore-ssl-errors=true)
    2. Once logged in, use a 'page.open(...)' to navigate to another site, within the site you just logged into
    3. Try to take a screenshot of the site you just navigated to

I have tried many different approaches to resolve the issue. I have tried using the logging/callback functions available (i.e. onLoadFinished(), onResourceRequested/Received(), etc.), but to no avail. It does appear that our page does not execute the onLoadFinished() when I try to navigate to a new site once logged in. I feel the issue stems from here. - That is why I had tried to take a screenshot in a callback associated with open() (as dictated by the documentation), AND by forcing a screenshot inside of a setTimeout(). Nothing works... the most that happens is that the screenshot will work if I wait for the site to log me off.

The ONLY screenshot I am able to take is when I initially log in. That is why I went the route of trying to keep the session alive, and simply navigating to other sites once logged in.

Could someone please help? I have spent almost two weeks on this issue, and have nothing to show. Please a help a lost soul who is spending his Birthday typing this issue =/

@vitallium any thoughts? (You had helped me once before, so just tagging you here b/c I'm utterly lost)

@Epskampie
Copy link

You could try a different way of navigating, try injecting a script into the page that changes document.location instead of using page.open() multiple times from the phantomjs side.

@sramzan
Copy link
Author

sramzan commented Nov 17, 2016

It's funny, I only thought to do something like after posting that issue. And, it worked! It looks like this behavior is due to my working with a single page app. So, of course, there is nothing wrong with phantom (shame on me). - Thanks for the prompt reply @Epskampie!!

Would it be worthwhile to have a method that 'moves' within a page, where essentially it just changes the fragment? The reason I ask, is b/c it is a tad cumbersome to have to do page.evalluate(), and then assume the page has changed. It's also unclear to readers of my code.

In addition, one looses the hook of 'onLoadFinished()' that 'open()' has. i.e. More logic has to be defined to navigate single page apps which are growing in numbers. I know that I could try and define something in 'onLoadFinished' but for obvious reasons that will also be cumbersome to do.

Example of proposed method:
page.openFragment(newFrag, callback())

Not sure if I'm an outlier with this issue, but it may be food for thought in an upcoming release.

@Epskampie
Copy link

If you have control over the webpage, you can use window.callPhantom() from the webpage to communicate various kind of events, for example when you have loaded a new page part through ajax.

@sramzan
Copy link
Author

sramzan commented Nov 18, 2016

I quickly skimmed the documentation... what I don't understand is how to get this to work with specific callbacks? It appears to fire off for all callbacks. - Please correct me if I'm wrong.

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants