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

'Not attached to an active page' error when opening a Twitter user authentication popup window #2716

Open
AutoAPEAI opened this issue Nov 29, 2023 · 0 comments

Comments

@AutoAPEAI
Copy link

AutoAPEAI commented Nov 29, 2023

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:

  1. Go to 'galxe.com'
  2. Click on 'Explore'
  3. Search 'galxeDAO' in the search bar
  4. Click a campaign which name contains 'GalxeDAO Tweet Like & Retweet'
  5. 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]'
  6. Click 'Detail >>' button
  7. 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

  1. 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;
  2. Tried remove the 'switchTo' and 'reload' lines after the 'await click("twitter.com", below("Call-to-Action"));' line, not working.
  3. Tried remove the 'setConfig' at the beginning, not working.
  4. Ran the code for a dozen times and for only once, the code worked perfectly with a 'reload' line after the 'click' action.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant