Bird
0
0

You want to run Selenium Python tests on multiple Python versions (3.10, 3.11, 3.12) using GitHub Actions. Which YAML snippet correctly sets up this matrix testing?

hard📝 Workflow Q15 of 15
Selenium Python - CI/CD Integration
You want to run Selenium Python tests on multiple Python versions (3.10, 3.11, 3.12) using GitHub Actions. Which YAML snippet correctly sets up this matrix testing?
Ajobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: 3.10, 3.11, 3.12 steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: pip install selenium - name: Run tests run: python test_suite.py
Bjobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: [3.10, 3.11, 3.12] - name: Install dependencies run: pip install selenium - name: Run tests run: python test_suite.py
Cjobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: [3.10, 3.11, 3.12] steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: pip install selenium - name: Run tests run: python test_suite.py
Djobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: [3.10 3.11 3.12] steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: pip install selenium - name: Run tests run: python test_suite.py
Step-by-Step Solution
Solution:
  1. Step 1: Understand matrix syntax

    The matrix must be a YAML list with square brackets and commas: [3.10, 3.11, 3.12].
  2. Step 2: Use matrix variable correctly

    The Python version in setup-python must use ${{ matrix.python-version }} to pick each version.
  3. Final Answer:

    The YAML snippet with strategy.matrix.python-version: [3.10, 3.11, 3.12] -> Option C
  4. Quick Check:

    Matrix list and variable syntax = A [OK]
Quick Trick: Use matrix with brackets and commas, reference with ${{ matrix.var }} [OK]
Common Mistakes:
  • Using commas missing or wrong brackets in matrix
  • Passing list directly to python-version input
  • Not referencing matrix variable in setup-python

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes