Problem with cookieStorage and Twitter
raulmonge opened this issue · 1 comments
raulmonge commented
Hello,
I was merging my puppeteer script to log in on Twitter to secret-agent and notice that the cookieStorage have some missing cookies that are not capture.
During the log in process there is some AJAX calls that set some cookies as, ct0 and auth_token.
After log in succesfully I call await agent.activeTab.cookieStorage.getItems()
But only return one of all the cookies.
It should return all of this ones
Here is my code
const agent = await new Agent({
upstreamProxyUrl: proxy.slice(0, -1)
});
await agent.goto("https://twitter.com/login");
//const { activeTab, document } = agent;
await agent.waitForPaintingStable();
var input = agent.document.querySelector('input[type="text"]');
await agent.activeTab.waitForElement(input, {
waitForVisible: true,
});
var continueButton = await agent.document.evaluate("//span[text()='Next']", agent.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
await agent.interact(
{ click: input },
{ type: this.email },
{ click: continueButton.singleNodeValue }
);
await agent.activeTab.waitForElement(input, {
waitForVisible: true,
});
console.log(await agent.document.cookie);
console.log(await agent.activeTab.cookieStorage.getItems());
var phoneUsernameCheck = await agent.document.evaluate("//span[text()='Phone or username']", agent.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if(phoneUsernameCheck.singleNodeValue){
continueButton = await agent.document.evaluate("//span[text()='Next']", agent.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
await agent.interact(
{ click: input },
{ type: this.username },
{ click: continueButton.singleNodeValue }
);
}
console.log(await agent.document.cookie);
console.log(await agent.activeTab.cookieStorage.getItems());
var password = agent.document.querySelector('input[type="password"]');
await agent.activeTab.waitForElement(password, {
waitForVisible: true,
});
continueButton = await agent.document.evaluate("//span[text()='Log in']", agent.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
await agent.interact(
{ click: password },
{ type: this.password },
{ click: continueButton.singleNodeValue }
);
console.log(await agent.document.cookie);
console.log(await agent.activeTab.cookieStorage.getItems());
await agent.activeTab.waitForLocation('change');
await agent.waitForPaintingStable();
console.log(await agent.document.cookie);
console.log(await agent.activeTab.cookieStorage.getItems());
//await agent.waitForMillis(300000);
await agent.close();
Thank you for your help
blakebyrnes commented
Hi @raulmonge, thanks for logging this ticket. Do you think you could send me your session database for this request? If you don't want to post on Github, I'm on Discord where you can DM me. how to find session db