skip to Main Content

I am attempting to script several devices using Playwright in order to adjust their configuration settings. Some models of devices request authentication via a popup dialog box in Chrome.

Popup Box

These popup boxes don’t trigger popup or dialog events in Playwright. I cannot target them for interaction. The web portals are built with JQuery. On some devices the JSON data transfer objects are exposed so I can call

await page.evaluate(() => {
            jQuery.ajaxSettings.username = 'uname';
            jQuery.ajaxSettings.password = 'pword';
       })

To fill in the correct fields, then hit the sign in button and it will authenticate me without triggering the popup. On other devices, it sends an http request that triggers a redirect to a seemingly blank set_password.html page. Then the popup is triggered. There’s no JS or any HTML that is loaded on the redirect page.

How can I get through this authentication step? If I go through myself in the browser, the cursor will automatically be placed in the text box. But Playwright doesn’t behave like this, so I haven’t been able to use the keyboard. I don’t know if I can mouse over this and select it. AS mentioned above, these popups don’t seem to trigger dialog or popup events in Playwright. I’ve tried looking through the request and response headers to see how and where it’s transferring the credentials so I can mimic that, but I am having trouble finding the right point. Any ideas?

2

Answers


  1. Looks like it’s Http Authentication.
    You can authenticate by creating new browser context and passing httpCredentials inside it.

    Reference

    const context = await browser.newContext({
      httpCredentials: {
        username: 'uname',
        password: 'psswd',
      },
    });
    const page = await context.newPage();
    await page.goto('url');
    
    Login or Signup to reply.
  2. Just simply call the page as

    http://uname:[email protected]

    This will authorize the call and open the page without the dialog

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search