0
0
Selenium Javatesting~20 mins

GitHub Actions configuration in Selenium Java - Practice Problems & Coding Challenges

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

Given this GitHub Actions workflow snippet, what will be the output of the Run tests step if the Java Selenium tests pass?

Selenium Java
name: Java Selenium Tests

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '17'
      - name: Run tests
        run: ./gradlew test
AError: Gradle not found
BBUILD FAILED\n1 test failed
CBUILD SUCCESSFUL in 10s\n5 tests completed, 0 failed
DPermission denied: ./gradlew
Attempts:
2 left
💡 Hint

Think about what happens when tests pass in a Gradle build.

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

Which step configuration correctly caches Gradle dependencies in a GitHub Actions workflow?

A
  - name: Cache Gradle
    uses: actions/cache@v3
    with:
      path: ~/.m2/repository
      key: ${{ runner.os }}-maven-${{ hashFiles('**/*.pom') }}
B
  - name: Cache Gradle
    uses: actions/cache@v3
    with:
      path: ~/.gradle/caches
      key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
      restore-keys: |
        ${{ runner.os }}-gradle-
C
  - name: Cache Gradle
    uses: actions/cache@v2
    with:
      path: ~/.gradle/wrapper
      key: ${{ runner.os }}-gradle-wrapper
D
  - name: Cache Gradle
    uses: actions/cache@v3
    with:
      path: ~/.gradle
      key: ${{ runner.os }}-gradle-cache
Attempts:
2 left
💡 Hint

Gradle caches are usually stored in ~/.gradle/caches.

Troubleshoot
advanced
2:00remaining
Diagnosing GitHub Actions Selenium Test Failure

A GitHub Actions workflow running Selenium Java tests on ubuntu-latest fails with the error java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property. What is the most likely cause?

AThe ChromeDriver executable is not installed or not found in the PATH on the runner.
BThe Java version is incompatible with Selenium WebDriver.
CThe workflow is missing the checkout step to get the source code.
DThe Gradle cache is corrupted causing driver download failure.
Attempts:
2 left
💡 Hint

Think about what Selenium needs to control the browser.

🔀 Workflow
advanced
2:30remaining
GitHub Actions Workflow for Parallel Selenium Tests

Which workflow configuration correctly runs Selenium Java tests in parallel on 3 different Java versions (11, 17, 20)?

A
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java-version: [11, 17, 20]
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: ${{ matrix.java-version }}
      - name: Run tests
        run: ./gradlew test
B
jobs:
  test11:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 11
        uses: actions/setup-java@v3
        with:
          java-version: 11
      - run: ./gradlew test
  test17:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: 17
      - run: ./gradlew test
  test20:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 20
        uses: actions/setup-java@v3
        with:
          java-version: 20
      - run: ./gradlew test
C
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: '11 17 20'
      - name: Run tests
        run: ./gradlew test
D
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        java-version: [11, 17, 20]
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: 11
      - name: Run tests
        run: ./gradlew test
Attempts:
2 left
💡 Hint

Look for matrix strategy usage for parallel jobs.

Best Practice
expert
2:30remaining
Best Practice for Secure Secrets in GitHub Actions

Which practice is the best way to securely use browser driver credentials or API keys in a GitHub Actions workflow for Selenium Java tests?

AHardcode the credentials directly in the workflow YAML file for easy access.
BSend credentials as plain text in workflow logs for debugging purposes.
CCommit the credentials in a separate config file in the repository and read it during the workflow.
DStore secrets in GitHub repository secrets and access them via <code>${{ secrets.SECRET_NAME }}</code> in the workflow.
Attempts:
2 left
💡 Hint

Think about how to keep sensitive data safe in public or shared repos.