GitHub Actions is a tool that helps automate tasks like testing, building, and deploying code whenever you make changes to your project.
Click to reveal answer
beginner
How do you trigger a GitHub Actions workflow?
You trigger a workflow by specifying events like pushing code, creating a pull request, or on a schedule in the workflow's YAML file.
Click to reveal answer
beginner
What file format is used to define GitHub Actions workflows?
Workflows are defined using YAML files placed in the .github/workflows directory of your repository.
Click to reveal answer
intermediate
How can you run Selenium tests using GitHub Actions?
You set up a job in the workflow that installs Python, Selenium, and browser drivers, then runs your test scripts automatically.
Click to reveal answer
beginner
What is the purpose of 'jobs' and 'steps' in a GitHub Actions workflow?
'Jobs' are groups of tasks that run on a machine, and 'steps' are individual commands or actions inside a job.
Click to reveal answer
Where do you place GitHub Actions workflow files in your repository?
Aroot directory
B.github/workflows
Csrc/
Dtests/
✗ Incorrect
Workflow files must be in the .github/workflows folder for GitHub to detect and run them.
Which file format is used to write GitHub Actions workflows?
AJSON
BXML
CYAML
DINI
✗ Incorrect
GitHub Actions workflows are written in YAML format.
What event can trigger a GitHub Actions workflow?
APush to repository
BOpening a text editor
CRunning a local script
DClosing the browser
✗ Incorrect
Workflows can be triggered by events like pushing code to the repository.
In GitHub Actions, what is a 'job'?
AA single command
BA branch name
CA type of repository
DA group of steps that run on a machine
✗ Incorrect
A job is a set of steps that run together on a runner machine.
To run Selenium tests in GitHub Actions, you need to:
AInstall Python, Selenium, and browser drivers in the workflow
BOnly push your test scripts
CUse a special Selenium GitHub repository
DRun tests manually on your computer
✗ Incorrect
The workflow must install required tools and drivers to run Selenium tests automatically.
Explain how to set up a GitHub Actions workflow to run Selenium Python tests automatically.
Think about the sequence of preparing the environment and running tests.
You got /5 concepts.
Describe the roles of 'jobs' and 'steps' in a GitHub Actions workflow.
Consider how tasks are organized and executed.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of integrating Selenium Python tests with GitHub Actions?
easy
A. To manually trigger tests only when needed
B. To write Selenium tests faster using GitHub's editor
C. To deploy the application to production automatically
D. To automatically run tests on code changes and catch bugs early
Solution
Step 1: Understand GitHub Actions role
GitHub Actions automates workflows like running tests when code changes.
Step 2: Identify Selenium test integration benefit
Running Selenium tests automatically helps find bugs early without manual effort.
Final Answer:
To automatically run tests on code changes and catch bugs early -> Option D
Quick Check:
Automation for early bug detection = B [OK]
Hint: GitHub Actions runs tests automatically on code changes [OK]
Common Mistakes:
Thinking tests run only manually
Confusing testing with deployment
Assuming GitHub edits test code automatically
2. Which YAML file location is correct for defining GitHub Actions workflows that run Selenium Python tests?
easy
A. .github/workflows/selenium_tests.yml
B. selenium_tests.yml
C. .github/actions/selenium_tests.yml
D. workflows/selenium_tests.yml
Solution
Step 1: Recall GitHub Actions workflow folder
Workflows must be inside the .github/workflows directory.
Step 2: Match correct file path
Only .github/workflows/selenium_tests.yml places the YAML file correctly inside .github/workflows.
Final Answer:
.github/workflows/selenium_tests.yml -> Option A
Quick Check:
Workflow YAML location = A [OK]
Hint: Workflows go inside .github/workflows folder [OK]
Common Mistakes:
Placing workflow files outside .github/workflows
Using .github/actions folder incorrectly
Missing the .github prefix
3. Given this GitHub Actions YAML snippet, what will happen when code is pushed to the main branch?
name: Selenium Tests
on:
push:
branches: [main]
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
- name: Run tests
run: python test_suite.py
medium
A. Tests will run on every push to any branch
B. Selenium tests will run automatically on every push to main branch
C. Tests will run only if manually triggered
D. The workflow will fail due to missing Python setup
Solution
Step 1: Analyze trigger event
The workflow triggers on push events to the main branch only.
Step 2: Check job steps
Steps include checkout, Python setup, installing selenium, and running tests, so tests run automatically.
Final Answer:
Selenium tests will run automatically on every push to main branch -> Option B
Quick Check:
Push to main triggers tests = C [OK]
Hint: Check 'on' section for event triggers in YAML [OK]
Common Mistakes:
Assuming tests run on all branches
Thinking manual trigger is needed
Missing Python setup step
4. You wrote this GitHub Actions workflow to run Selenium tests but it fails with "command not found: python":
name: Selenium Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: python test_suite.py
What is the likely fix?
medium
A. Add a step to set up Python using actions/setup-python
B. Change 'python' to 'python3' in the run command
C. Remove the checkout step
D. Add 'pip install selenium' before running tests
Solution
Step 1: Identify missing Python setup
The error "command not found: python" means Python is not installed or set up in the runner.
Step 2: Add Python setup step
Using actions/setup-python installs and configures Python before running tests.
Final Answer:
Add a step to set up Python using actions/setup-python -> Option A
Quick Check:
Python setup missing causes error = D [OK]
Hint: Always set up Python before running Python commands [OK]
Common Mistakes:
Assuming python3 is available without setup
Skipping Python setup step
Removing checkout step unnecessarily
5. 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?