0
0
Selenium Pythontesting~20 mins

GitHub Actions integration in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GitHub Actions Selenium Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
GitHub Actions Workflow Run Result

You have a GitHub Actions workflow configured to run Selenium tests using Python. The workflow file includes a step to install dependencies and run pytest. What will be the output if the tests fail?

Selenium Python
name: Selenium Tests
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.12'
      - name: Install dependencies
        run: pip install selenium pytest
      - name: Run tests
        run: pytest tests/
AThe workflow run will be marked as failed and the logs will show pytest failure details.
BThe workflow run will be marked as successful regardless of test failures.
CThe workflow run will be canceled automatically without any logs.
DThe workflow run will retry the tests infinitely until they pass.
Attempts:
2 left
💡 Hint

Think about how GitHub Actions treats non-zero exit codes from commands.

Configuration
intermediate
2:00remaining
Correct GitHub Actions Step to Cache Python Dependencies

You want to speed up your Selenium Python tests in GitHub Actions by caching the pip packages. Which step configuration correctly caches the dependencies?

A
- name: Cache pip
  uses: actions/cache@v3
  with:
    path: ~/.cache/pip
    key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
    restore-keys: |
      ${{ runner.os }}-pip-
B
- name: Cache pip
  run: pip cache save ~/.cache/pip
C
- name: Cache pip
  uses: actions/cache@v1
  with:
    path: /usr/local/lib/python3.12/site-packages
    key: pip-cache
D
- name: Cache pip
  uses: actions/cache@v3
  with:
    path: ~/.pip
    key: ${{ runner.os }}-pip-cache
Attempts:
2 left
💡 Hint

Look for the official cache action usage and correct cache path for pip.

🔀 Workflow
advanced
2:00remaining
Triggering GitHub Actions Workflow on Pull Request and Push

You want your Selenium Python tests to run automatically on both pull requests and pushes to the main branch. Which on configuration in the workflow file achieves this?

A
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - develop
B
on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - '*'
C
on:
  push:
    branches:
      - develop
  pull_request:
    branches:
      - main
D
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
Attempts:
2 left
💡 Hint

Consider which branches should trigger the workflow for both push and pull request events.

Troubleshoot
advanced
2:00remaining
Diagnosing Selenium Test Failures in GitHub Actions

Your Selenium tests run fine locally but fail in GitHub Actions with errors related to the browser driver not found. What is the most likely cause?

AThe tests are running too fast in GitHub Actions causing timing issues.
BThe GitHub Actions runner does not have the browser driver installed or configured in PATH.
CThe Selenium version used locally is different from the one in GitHub Actions.
DThe GitHub Actions workflow file is missing the <code>actions/checkout</code> step.
Attempts:
2 left
💡 Hint

Think about what is needed for Selenium to control a browser in a fresh environment.

Best Practice
expert
2:00remaining
Best Practice for Securely Storing Browser Driver Versions in GitHub Actions

You want to ensure your Selenium tests use a specific browser driver version in GitHub Actions and keep this version configurable without hardcoding it in the workflow file. What is the best practice?

AStore the browser driver version as a secret in GitHub repository settings and reference it in the workflow using <code>secrets</code>.
BHardcode the browser driver version directly in the workflow YAML file under the install step.
CStore the browser driver version in a separate configuration file in the repository and read it during the workflow run.
DUse the latest browser driver version always without specifying any version.
Attempts:
2 left
💡 Hint

Consider how to keep configuration flexible and visible to the workflow without exposing secrets unnecessarily.