-
Notifications
You must be signed in to change notification settings - Fork 453
Open
Description
Describe the bug
When attempting to automate the user authentication process on Twitter, specifically when dealing with the authentication popup window, Taiko encounters the error message "Not attached to an active page."
To Reproduce
Steps (or script) to reproduce the behavior:
- Go to 'galxe.com'
- Click on 'Explore'
- Search 'galxeDAO' in the search bar
- Click a campaign which name contains 'GalxeDAO Tweet Like & Retweet'
- Click the expand button with xpath '//*[@id='ga-data-campaign-model-2']/div[2]/div[1]/div/div[4]/div[2]/div/div[1]/div/div/div[2]/div[1]/div/button/div[1]/div[1]'
- Click 'Detail >>' button
- Click the Twitter url below the ''Call-to-Action" text
const { openBrowser, goto, click, write, switchTo, closeTab, closeBrowser, setConfig, into, textBox } = require('taiko');
const { generateToken} = require('authenticator');
(async () => {
try {
await openBrowser();
setConfig({waitForNavigation: false, observe: true });
await goto("galxe.com");
await click("Explore");
await write("galxeDAO", into(textBox("Search")));
await click("GalxeDAO Tweet Like & Retweet");
await click($("//*[@id='ga-data-campaign-model-2']/div[2]/div[1]/div/div[4]/div[2]/div/div[1]/div/div/div[2]/div[1]/div/button/div[1]/div[1]"));
await click("Detail >>");
await click("twitter.com", below("Call-to-Action"));
await switchTo(/twitter/);
await reload();
// tw-auth
await click("Phone, email, or username", { force: true });
await write("");
await click("Next");
await write("");
await click("Log in");
//2fa-auth
let otp = generateToken("");
await write(otp);
await click("Next");
// perform action & close tabs
await click("Like");
await closeTab(/X/);
await closeTab(/Liker/);
} catch (error) {
console.error(error);
} finally {
await closeBrowser();
}
})();
Logs
Browser opened
✔ Navigated to URL http://galxe.com
✔ Clicked element matching text "Explore" 1 times
✔ Wrote galxeDAO into the textBox with label Search
✔ Clicked element matching text "GalxeDAO Tweet Like & Retweet" 1 times
" ✔ Clicked customSelector with query //*[@id='ga-data-campaign-model-2']/div[2]/div[1]/div/div[4]/div[2]/div/div[1]/div/div/div[2]/div[1]/div/button/div[1]/div[1] 1 times"
✔ Clicked element matching text "Detail >>" 1 times
✔ Clicked element matching text "twitter.com" 1 times
ProtocolError: Not attached to an active page
at /usr/local/lib/node_modules/taiko/node_modules/chrome-remote-interface/lib/chrome.js:94:35
at Chrome._handleMessage (/usr/local/lib/node_modules/taiko/node_modules/chrome-remote-interface/lib/chrome.js:257:17)
at WebSocket.<anonymous> (/usr/local/lib/node_modules/taiko/node_modules/chrome-remote-interface/lib/chrome.js:235:22)
at WebSocket.emit (node:events:517:28)
at Receiver.receiverOnMessage (/usr/local/lib/node_modules/taiko/node_modules/ws/lib/websocket.js:1068:20)
at Receiver.emit (node:events:517:28)
at Receiver.dataMessage (/usr/local/lib/node_modules/taiko/node_modules/ws/lib/receiver.js:517:14)
at /usr/local/lib/node_modules/taiko/node_modules/ws/lib/receiver.js:468:23
at /usr/local/lib/node_modules/taiko/node_modules/ws/lib/permessage-deflate.js:308:9
at /usr/local/lib/node_modules/taiko/node_modules/ws/lib/permessage-deflate.js:391:7 {
request: {
method: 'Page.bringToFront',
params: undefined,
sessionId: undefined
},
response: { code: -32000, message: 'Not attached to an active page' }
}
✔ Switched to tab matching /twitter/
✔ Browser closed
Expected behavior
Taiko should be able to interact with and manipulate elements within the Twitter authentication popup window seamlessly.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions:
- Taiko: [Version: 1.3.10 (Chromium: 110.0.5478.0) RELEASE]
- OS [macOS Sonoma Version 14.1.1 (23B81) ]
- Node.js [v18.18.0]
Additional context
- The code works in a local interactive mode (i.e. type 'taiko' in command line), still getting the warning message says "Uncaught Not attached to an active page", but I was able to run the following codes manually line by line;
- Tried remove the 'switchTo' and 'reload' lines after the 'await click("twitter.com", below("Call-to-Action"));' line, not working.
- Tried remove the 'setConfig' at the beginning, not working.
- Ran the code for a dozen times and for only once, the code worked perfectly with a 'reload' line after the 'click' action.
Metadata
Metadata
Assignees
Labels
No labels