My Playwright test execution hangs after login in GitHub Actions - Stack Overflow

My Playwright test is running fine in debug and normal mode when I ran on local, but when I've tri

My Playwright test is running fine in debug and normal mode when I ran on local, but when I've tried the same through GitHub Actions it's hung to launch the application. My login involves Microsoft Authenticator and then it opens the application page and that works fine on local. It's not delay issue I tried with long delay there still it has not worked. I checked trace and that shows login is successful and after that it's in a blank processing window and never launched the landing page. Can anyone help me to figure out the issue? My workflow is:

name: Playwright Tests
on:
  push:
    branches: [ <MyBranch> ]
  pull_request:
    branches: [ <MyBranch> ]
  workflow_dispatch: # Enable manual trigger

jobs:
  test:
    timeout-minutes: 30 # Timeout for the entire job
    runs-on: macos-latest

    strategy:
      fail-fast: false
      matrix:
        shard: [1/4]
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
          node-version: 20

    - name: Install dependencies
      run: npm ci 

    - name: Install Playwright browsers
      run: npx playwright install 
      
    - name: Run Playwright Test on Microsoft Edge (Headless)
      run: npx playwright test LoginTest.spec.js --shard ${{ matrix.shard }} 
          
    - name: Upload Playwright report
      if: always()
      uses: actions/upload-artifact@v4
      with:
          name: playwright-report
          path: playwright-report
          retention-days: 1

My Playwright test is running fine in debug and normal mode when I ran on local, but when I've tried the same through GitHub Actions it's hung to launch the application. My login involves Microsoft Authenticator and then it opens the application page and that works fine on local. It's not delay issue I tried with long delay there still it has not worked. I checked trace and that shows login is successful and after that it's in a blank processing window and never launched the landing page. Can anyone help me to figure out the issue? My workflow is:

name: Playwright Tests
on:
  push:
    branches: [ <MyBranch> ]
  pull_request:
    branches: [ <MyBranch> ]
  workflow_dispatch: # Enable manual trigger

jobs:
  test:
    timeout-minutes: 30 # Timeout for the entire job
    runs-on: macos-latest

    strategy:
      fail-fast: false
      matrix:
        shard: [1/4]
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
      with:
          node-version: 20

    - name: Install dependencies
      run: npm ci 

    - name: Install Playwright browsers
      run: npx playwright install 
      
    - name: Run Playwright Test on Microsoft Edge (Headless)
      run: npx playwright test LoginTest.spec.js --shard ${{ matrix.shard }} 
          
    - name: Upload Playwright report
      if: always()
      uses: actions/upload-artifact@v4
      with:
          name: playwright-report
          path: playwright-report
          retention-days: 1
Share Improve this question edited Mar 4 at 11:05 jonrsharpe 122k30 gold badges268 silver badges476 bronze badges asked Mar 4 at 11:02 Prosenjit MukherjeeProsenjit Mukherjee 91 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

My login involves Microsoft Authenticator and then it opens the application page and that works fine on local.

If you run it in GitHub Actions workflow, it runs on a different machine, which has no:

  • display server (like X)
  • web browser

What you could do though:

  • Make the login token based, preferably short-lived
  • Output the login link so you can access the website from your own workstation (making automation with GHA somewhat pointless) in order to login
  • Install necessary dependencies in some kind of docker image

Also, from a quick check on playwright GitHub Actions documentation you should try adding --with-deps flag:

...
- name: Install dependencies
  run: npm ci
- name: Install Playwright Browsers
  run: npx playwright install --with-deps
...

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745048447a4608238.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信