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

[BUG] Can't click 2FA duo button. #2573

Closed
Everthings opened this issue Jun 14, 2020 · 7 comments
Closed

[BUG] Can't click 2FA duo button. #2573

Everthings opened this issue Jun 14, 2020 · 7 comments

Comments

@Everthings
Copy link

Everthings commented Jun 14, 2020

Context:

  • Playwright Version: 1.1.1
  • Operating System: Windows
  • Node version: 12.13.1
  • Browser: Chromium
  • Extra:

Code Snippet

const playwright = require("playwright");

(async () => {
  const browser = await playwright.chromium.launch({ headless: false });
  const page = await browser.newPage();
  await page.goto("[WEBSITE HERE]");

  const USERNAME_SELECTOR = "id=idToken1";
  const PASSWORD_SELECTOR = "id=idToken2";
  const LOGIN_BUTTON_SELECTOR = "id=loginButton_0";
  const DUO_AUTH_SELECTOR = "css=.auth-button";

  const USERNAME = "[USERNAME HERE]";
  const PASSWORD = "[PASSWORD HERE]";

  // working
  await page.fill(USERNAME_SELECTOR , USERNAME );
  await page.fill(PASSWORD_SELECTOR, PASSWORD);
  await page.click(LOGIN_BUTTON_SELECTOR);

  // wait for duo iframe to appear
  await page.waitForSelector("iframe[id=duo_iframe]");

  // get iframe
  const frame = await page.mainFrame().childFrames()[0];

  // test to see if button can be found
  const inner = await frame.innerHTML(DUO_AUTH_SELECTOR);
  console.log(inner); // prints '<!-- -->Send Me a Push'

  // not working
  await frame.click(DUO_AUTH_SELECTOR);

  await browser.close();
})();

Describe the bug

I'm writing a script to automate the process of logging into a specific site. After the login page (which the script handles correctly), the site presents a duo 2FA button that needs to be pressed.

The script above manages to log in but fails to click the 'duo-auth button'. The 'duo-auth button' is part of an iframe.

frame.innerHTML returns the expected inner HTML, so it seems like the selector is able to find the button.

The part of the iframe that contains the button is shown below. The button has text 'Send Me a Push'.

<div id="auth_methods">
  <fieldset data-device-index="phone1" class="">
    <h2 class="medium-or-larger auth-method-header">
      Choose an authentication method
    </h2>

    <div class="row-label push-label">
      <input type="hidden" name="factor" value="Duo Push" />
      <span class="label factor-label">
        <i class="icon-smartphone-check"></i>
        Duo Push
      </span>
      <button tabindex="2" type="submit" class="positive auth-button">
        <!-- -->Send Me a Push
      </button>
    </div>

    <div class="row-label phone-label">
      <input type="hidden" name="factor" value="Phone Call" />
      <span class="label factor-label">
        <i class="icon-call-ringing" alt="" role="presentation"></i>
        Call Me
      </span>
      <button tabindex="2" type="submit" class="positive auth-button">
        <!-- -->Call Me
      </button>
    </div>

    <div class="passcode-label row-label">
      <input type="hidden" name="factor" value="Passcode" />
      <span class="label factor-label">
        <i class="icon-smartphone-ellipsis" alt="" role="presentation"></i>
        Passcode
      </span>
      <div class="passcode-input-wrapper">
        <input
          type="text"
          name="passcode"
          autocomplete="off"
          data-index="phone1"
          class="hidden passcode-input"
          placeholder="ex. 867539"
          aria-label="passcode"
          tabindex="2"
        />
        <div class="next-passcode-msg" role="alert" aria-live="polite"></div>
      </div>
      <button
        id="passcode"
        tabindex="2"
        type="submit"
        class="positive auth-button"
      >
        <!-- -->Enter a Passcode
      </button>
      <input name="phone-smsable" type="hidden" value="True" />
      <input name="mobile-otpable" type="hidden" value="True" />
      <input name="next-passcode" type="hidden" value="None" />
    </div>
  </fieldset>
  <input type="hidden" name="has-token" value="false" />
</div>
@pavelfeldman
Copy link
Member

Could you run your script with the DEBUG=pw:api environment variable?

@Everthings
Copy link
Author

Everthings commented Jun 15, 2020

Works now when I run on firefox.

  pw:api => firefox.launch started +0ms
  pw:api <= firefox.launch succeeded +3s
  pw:api => page.goto started +2s
  pw:api   navigating to "[site]", waiting until "load" +2ms
  pw:api   navigated to "[site]" +1s
  pw:api   "domcontentloaded" event fired +217ms
  pw:api   "load" event fired +15ms
  pw:api <= page.goto succeeded +2ms
  pw:api => page.fill started +2ms
  pw:api   waiting for selector "id=idToken1" +5ms
  pw:api     selector resolved to visible <input value="" type="text" required="" autofocus="" id…/> +13s
  pw:api   elementHandle.fill("[usrnm]") +3ms
  pw:api <= page.fill succeeded +84ms
  pw:api => page.fill started +2ms
  pw:api   waiting for selector "id=idToken2" +0ms
  pw:api     selector resolved to visible <input value="" required="" id="idToken2" type="passwor…/> +41ms
  pw:api   elementHandle.fill("[pass]") +2ms
  pw:api <= page.fill succeeded +116ms
  pw:api => page.click started +2ms
  pw:api   waiting for selector "id=loginButton_0" +2ms
  pw:api     selector resolved to visible <input index="0" type="submit" role="button" value="Log…/> +67ms
  pw:api   attempting page.click action +3ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +74ms
  pw:api     scrolling into view if needed +3ms
  pw:api     done scrolling +25ms
  pw:api     checking that element receives pointer events at (631.5,372.14) +75ms
  pw:api     element does receive pointer events, continuing input action +46ms
  pw:api     performing page.click action +3ms
  pw:api     page.click action done +85ms
  pw:api     waiting for scheduled navigations to finish +2ms
  pw:api     navigations have finished +2ms
  pw:api <= page.click succeeded +2ms
  pw:api => page.waitForSelector started +3ms
  pw:api   waiting for selector "iframe[id=duo_iframe]" to be visible +5ms
  pw:api     selector resolved to visible <iframe id="duo_iframe" data-submit-callback="function d…></iframe> +5s
  pw:api <= page.waitForSelector succeeded +38ms
  pw:api => frame.getAttribute started +38ms
  pw:api   waiting for selector "css=.auth-button" +3ms
  pw:api     selector resolved to visible <button tabindex="2" type="submit" class="auth-button po…></button> +3s
  pw:api <= frame.getAttribute succeeded +54ms
null
  pw:api => frame.click started +27ms
  pw:api   waiting for selector "css=.auth-button" +2ms
  pw:api     selector resolved to hidden <button tabindex="2" type="submit" class="auth-button po…></button> +36ms
  pw:api   attempting frame.click action +16ms
  pw:api     waiting for element to be displayed, enabled and not moving +16ms
  pw:api     element is displayed and does not move +518ms
  pw:api     scrolling into view if needed +3ms
  pw:api     done scrolling +35ms
  pw:api     checking that element receives pointer events at (840.5,308.18) +62ms
  pw:api     element does receive pointer events, continuing input action +86ms
  pw:api     performing frame.click action +3ms
  pw:api     frame.click action done +197ms
  pw:api     waiting for scheduled navigations to finish +3ms
  pw:api     navigations have finished +4ms
  pw:api <= frame.click succeeded +30ms

@Everthings
Copy link
Author

Everthings commented Jun 15, 2020

However, running on chromium results in a seemingly infinite loop.

  pw:api => chromium.launch started +0ms
  pw:api <= chromium.launch succeeded +708ms
  pw:api => page.goto started +602ms
  pw:api   navigating to "[site]", waiting until "load" +3ms
  pw:api   navigated to "[site]" +1s
  pw:api   "load" event fired +319ms
  pw:api <= page.goto succeeded +3ms
  pw:api => page.fill started +5ms
  pw:api   waiting for selector "id=idToken1" +16ms
  pw:api     selector resolved to visible <input value="" type="text" required="" autofocus="" id…/> +4s
  pw:api   elementHandle.fill("[usrnm]") +3ms
  pw:api <= page.fill succeeded +31ms
  pw:api => page.fill started +12ms
  pw:api   waiting for selector "id=idToken2" +1ms
  pw:api     selector resolved to visible <input value="" required="" id="idToken2" type="passwor…/> +24ms
  pw:api   elementHandle.fill("[pass]") +6ms
  pw:api <= page.fill succeeded +27ms
  pw:api => page.click started +2ms
  pw:api   waiting for selector "id=loginButton_0" +1ms
  pw:api     selector resolved to visible <input index="0" type="submit" role="button" value="Log…/> +9ms
  pw:api   attempting page.click action +12ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +92ms
  pw:api     scrolling into view if needed +1ms
  pw:api     done scrolling +4ms
  pw:api     checking that element receives pointer events at (631.5,371.94) +3ms
  pw:api     element does receive pointer events, continuing input action +27ms
  pw:api     performing page.click action +4ms
  pw:api     page.click action done +34ms
  pw:api     waiting for scheduled navigations to finish +1ms
  pw:api     navigations have finished +15ms
  pw:api <= page.click succeeded +11ms
  pw:api => page.waitForSelector started +4ms
  pw:api   waiting for selector "iframe[id=duo_iframe]" to be visible +2ms
  pw:api     selector resolved to visible <iframe id="duo_iframe" data-submit-callback="function d…></iframe> +2s
  pw:api <= page.waitForSelector succeeded +10ms
  pw:api => frame.getAttribute started +17ms
  pw:api   waiting for selector "css=.auth-button" +11ms
  pw:api     selector resolved to hidden <button tabindex="2" type="submit" class="positive auth-…></button> +2s
  pw:api <= frame.getAttribute succeeded +4ms
null
  pw:api => frame.click started +11ms
  pw:api   waiting for selector "css=.auth-button" +1ms
  pw:api     selector resolved to hidden <button tabindex="2" type="submit" class="positive auth-…></button> +9ms
  pw:api   attempting frame.click action +11ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +536ms
  pw:api     scrolling into view if needed +1ms
  pw:api     done scrolling +2ms
  pw:api     checking that element receives pointer events at (519,56) +9ms
  pw:api     element does not receive pointer events +11ms
  pw:api   retrying frame.click action +1ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +9ms
  pw:api     scrolling into view if needed +7ms
  pw:api     done scrolling +2ms
  pw:api     checking that element receives pointer events at (519,56) +3ms
  pw:api     element does not receive pointer events +10ms
  pw:api   retrying frame.click action +3ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +11ms
  pw:api     scrolling into view if needed +10ms
  pw:api     done scrolling +5ms
  pw:api     checking that element receives pointer events at (519,56) +14ms
  pw:api     element does not receive pointer events +22ms
  pw:api   retrying frame.click action +3ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +10ms
  pw:api     scrolling into view if needed +8ms
  pw:api     done scrolling +3ms
  pw:api     checking that element receives pointer events at (519,56) +4ms
  pw:api     element does not receive pointer events +23ms
  pw:api   retrying frame.click action +3ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +24ms
  pw:api     scrolling into view if needed +8ms
  pw:api     done scrolling +3ms
  pw:api     checking that element receives pointer events at (519,56) +4ms
  pw:api     element does not receive pointer events +26ms
  pw:api   retrying frame.click action +1ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +24ms
  pw:api     scrolling into view if needed +2ms
  pw:api     done scrolling +3ms
  pw:api     checking that element receives pointer events at (519,56) +15ms
  pw:api     element does not receive pointer events +14ms
  pw:api   retrying frame.click action +10ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +39ms
  pw:api     scrolling into view if needed +1ms
  pw:api     done scrolling +3ms
  pw:api     checking that element receives pointer events at (519,56) +19ms
  pw:api     element does not receive pointer events +14ms
  pw:api   retrying frame.click action +8ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +17ms
  pw:api     scrolling into view if needed +15ms
  pw:api     done scrolling +5ms
  pw:api     checking that element receives pointer events at (519,56) +3ms
  pw:api     element does not receive pointer events +14ms
  pw:api   retrying frame.click action +11ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +17ms
  pw:api     scrolling into view if needed +11ms
  pw:api     done scrolling +5ms
  pw:api     checking that element receives pointer events at (519,56) +15ms
  pw:api     element does not receive pointer events +28ms
  pw:api   retrying frame.click action +2ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +39ms
  pw:api     scrolling into view if needed +10ms
  pw:api     done scrolling +5ms
  pw:api     checking that element receives pointer events at (519,56) +19ms
  pw:api     element does not receive pointer events +12ms
  pw:api   retrying frame.click action +12ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +23ms
  pw:api     scrolling into view if needed +10ms
  pw:api     done scrolling +4ms
  pw:api     checking that element receives pointer events at (519,56) +11ms
  pw:api     element does not receive pointer events +12ms
  pw:api   retrying frame.click action +5ms
  pw:api     waiting for element to be displayed, enabled and not moving +2ms
  pw:api     element is displayed and does not move +22ms
  pw:api     scrolling into view if needed +7ms
  pw:api     done scrolling +4ms
  pw:api     checking that element receives pointer events at (519,56) +2ms
  pw:api     element does not receive pointer events +25ms
  pw:api   retrying frame.click action +2ms
  pw:api     waiting for element to be displayed, enabled and not moving +1ms
  pw:api     element is displayed and does not move +26ms
  pw:api     scrolling into view if needed +1ms
  pw:api     done scrolling +2ms
  pw:api     checking that element receives pointer events at (519,56) +16ms
  pw:api     element does not receive pointer events +12ms
  pw:api   retrying frame.click action +13ms
  pw:api     waiting for element to be displayed, enabled and not moving +14ms
  pw:api     element is displayed and does not move +10ms
  pw:api     scrolling into view if needed +9ms
  pw:api     done scrolling +4ms
  pw:api <= frame.click failed +47ms // had to manually ctr+c

@pavelfeldman
Copy link
Member

Somehow Playwright thinks that some other element is occluding the button on Chromium and it can't click the Send me a push button. We would need to look at the DOM of your page and debug it to be helpful. Any chance there is a repro that you can share with us? Can be done privately.

@Everthings
Copy link
Author

@pavelfeldman Invited you to a private repo containing the page HTML. Let me know if you need more information.

@pavelfeldman
Copy link
Member

@aslushnikov
Copy link
Contributor

I'll close this since the discussion has stalled. (Feel free to re-open if not)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants