Rayrun
← Back to Discord Forum

Automate Playwright tests with Azure authentication(MFA)

Hi all, Cannot automate Playwright tests with Azure authentication - prompted to email code verification, Please Help

This thread is trying to answer question "How can one automate Playwright tests with Azure authentication that requires MFA, especially when running headless on GitHub Actions?"

18 replies

You can't really automate MFA authentication. Most likely you'll need to login manually and save session storage for further testing https://playwright.dev/docs/auth#session-storage

mukulbhatt1564

If you have username and password, there are some libraries that generates MFA

THanks @mukulbhatt1564 @skorp32, but headless how to add otp manually

@skorp32 I logged in and it asked for MFA OTP (phone number), but it's headless, so I can't add otp.

why not headed?

I am running on github actions

in local i type manually it works. but in github actions i cannot do like this

@skorp32: how to run headed?

how to run headed?

@mir1412: @mir1412 thanks, let me check

@mir1412 thanks, let me check

@janagar - If you are looking for some starter code you can check out https://github.com/rajyraman/playwright-azure-ad-mfa. I looked into this problem as well.

@natrajy: hi @natrajy thanks, i already walkthrough this. let me check it again

hi @natrajy thanks, i already walkthrough this. let me check it again

Hi @skorp32, thanks, But if i add auth/session.json in .gitignore means how it run on github actions?

add it to secrets if you don't want to commit it to git

@skorp32: ok mindaugas, thanks i will check

ok mindaugas, thanks i will check

I added auth.json secrets to github; how can I access them in my code now? @skorp32 previously i access via auth.json file in my local playwrght config

dunno, I'm not using github actions, there should be documentation on how to access gh secrets in code

@skorp32: thanks again, will check

thanks again, will check

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].