0

I am trying to test a website that requires a login for the site. The issue I am running into is that pa11y-ci is not able to get past the login screen. I know the username and password are correct. I have tried to set the useIncognitoBrowserContext to false with and without quotes. I have also tried to login via the browser and then steal the cookie from the browser. Below is what my .pa11yci file looks like right now.

{
  "defaults": {
     "useIncognitoBrowserContext": "false"
  },
  "urls": [
    {
      "url": "https://example.com/#/login?redirect=%2Fwidgets&isFreshLogin=true",
      "actions": [
         "set field #username to username@example.com",
         "set field #password to p@ssword123",
         "click element #login",
         "wait for element #widgets-list to be visible",
         "navigate to https://example.com/#/widgets"
      ],
      "screenCapture": "./after-login.png"
    },
    {
      "url": "https://example.com/#/widgets",
      "headers": {
        "Cookie": "login-token=0d3ce622baab4f46b31067bbcbfb5a4f"
      },
      "screenCapture": "./widgets.png"
    },
    "https://example.com/#/projects"
  ]
}
brownie_1
  • 1
  • 1

1 Answers1

0

This is (an excerpt) of what works for me, with useIncognitoBrowserContext false (no quotes).

"defaults" : {
  "useIncognitoBrowserContext": false
},

"urls" : [
  {
    "__NOTE"  : "this should always be FIRST (if browser context is preserved)",
    "url"     : "http://localhost:4200/login",
    "actions" : [
      "navigate to http://localhost:4200/login",
      "wait for element #login to be visible",
      "screen capture .pa11y/login0.png",
      "set field #username to Pa11y Author",
      "set field #password to Pa11y Password",
      "click element #login",
      "wait for element #appMenu to be visible",
      "screen capture .pa11y/login1.png"
    ]
  },

  {
    "url"     : "http://localhost:4200/activity-list",
    "actions" : [
      "navigate to http://localhost:4200/activity-list",
      "screen capture .pa11y/activity-list0.png",
      "wait for path to be /activity-list",
      "screen capture .pa11y/activity-list1.png"
    ]
  },
  ...
]