-
Notifications
You must be signed in to change notification settings - Fork 72
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
[FEATURE REQUEST] Window Data Inject #50
Comments
There isn't currently an explicit configuration for
Note that |
@tungs This did not seem to work, I didn't even see the log triggering... Also tried writing it like this, which didn't work either:
|
|
So yea, this renders the error page given by react, the TS/React error shown is a result of window.renderData not being injected with data. CONSOLE LOGS
|
I'll try testing with console.log now. |
A hacky workaround that i'm using is to inside e.g: await page.evaluate((data) => {
const serializedData = JSON.stringify(data)
localStorage.setItem(‘data’, serializedData)
}, data)
await page.evaluate(() => {
location.reload(true)
}) |
Just realized I wasn't on the latest release, I was |
Updated to preparePage: async page => {
console.log('Running preparePage!');
console.log(`page`, page);
await page.evaluate(data => {
console.log(`data`, data);
const serializedData = JSON.stringify(data);
localStorage.setItem('renderData', serializedData);
}, renderData);
await page.evaluate(() => {
console.log(`location`, location);
location.reload(true);
});
}, I get this: CONSOLE LOGS
Analysis
const [renderData, setRenderData] = useState<App.renderAnimData>(
//@ts-ignore
window.renderData ? window.renderData : JSON.parse(localStorage.getItem('renderData')),
); |
@tungs After updating my timecut version I did start to see |
Update - I've gotten localStorage to work though first going to the page async navigatePageToURL({ page, url, log }) {
log('navigatePageToURL()');
await page.goto(url, { waitUntil: 'networkidle0' });
await page.evaluate(data => {
const serializedData = JSON.stringify(data);
window.localStorage.setItem('renderData', serializedData);
location.reload(true);
}, renderData);
log('Going to ' + url + '...');
return await page.goto(url, { waitUntil: 'networkidle0' });
}, |
Hi guys, |
Is your feature request related to a problem? Please describe.
I want to inject data into the window as described here: https://stackoverflow.com/a/56318041/1715153
I've tried this with the regular puppeteer package using
page.evaluate()
method and it works.Example:
However, if I try to inject window data with timecut's
preparePage
ornavigatePageToURL
, neither seems to work. I need to pass this data object into the window so my frontend website can pick up the data. I tried to pass the data as an encoded url but that doesn't work because it gets too long and causes chromium431 error
.Example of what I've tried with timecut:
Describe the solution you'd like
Some way to inject data into the window before the page loads!
Describe alternatives you've considered
Using puppeteer instead which is not ideal.
P.S. I'm not sure if this is a bug or a feature request, I just need access to the puppeteer window during
page.evaluate()
.The text was updated successfully, but these errors were encountered: