Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Contributing Example for WebDriver Selenium #20

@Nosferican

Description

@Nosferican

I would make the PR, but I am not well versed in JS.

For .github/workflows/selenium-service.yml

name: CI

on:
    push:
        branches:
            - master
    pull_request:
        branches:
            - master
    release:
        types:
            - created

jobs:
    container-job:
        runs-on: ubuntu-latest
      
        # runs all of the steps inside the specified container rather than on the VM host.  
        # Because of this the network configuration changes from host based network to a container network.
        container:
            image: node:current

        services:
            selenium:
                image: selenium/standalone-chrome
                # needed because the selenium container does not provide a healthcheck
                options: --health-cmd '/opt/bin/check-grid.sh'
      
        steps:
            - uses: actions/checkout@v1
            - run: npm ci
                working-directory: ./selenium
            - run: node client.js
                working-directory: ./selenium
                # use selenium for the host here because we have specified a container for the job.
                # If we were running the job on the VM this would be localhost
                SELENIUM_HOST: selenium
                # The default port will be the one used when we have specified a container for the job.
                SELENIUM_PORT: 4444
  
    # Runs all steps on the VM
    # The service containers will use host port binding instead of container networking so you access them via localhost rather than the service name
    vm-job:
        runs-on: ubuntu-latest
      
        services:
            selenium:
                image: selenium/standalone-chrome
                ports:
                    # will assign a random free host port
                    - 4444/tcp
                    # needed because the selenium container does not provide a healthcheck
                options: --health-cmd '/opt/bin/check-grid.sh'
        
        steps:
            - uses: actions/checkout@v1
            - run: npm ci
            working-directory: ./selenium
            - run: node client.js
            working-directory: ./selenium
            env:
                # use localhost for the host here because we are running the job on the VM.
                # If we were running the job on in a container this would be selenium
                SELENIUM_HOST: localhost
                SELENIUM_PORT: ${{ job.services.selenium.ports[4444] }} # get randomly assigned published port

For the selenium/client.js,

Something like

response = HTTP.post("http://$SELENIUM_HOST:$SELENIUM_PORT/wd/hub",
                     [("Content-Type" => "application/json")],
                     "{\"desiredCapabilities\":{\"browserName\":\"chrome\"}}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions