From 21eb33b5896a2089a6f86fb032e3de583b9adad3 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Sun, 16 Jun 2024 18:21:30 -0500 Subject: [PATCH 1/7] Configure firefox --- .github/workflows/automation.yml | 12 ++++++-- Tests/chrome/agenciaclickone/IndexView.robot | 0 .../firefox/agenciaclickone/ContactForm.robot | 28 +++++++++++++++++++ Tests/firefox/agenciaclickone/IndexView.robot | 0 docker-compose.yml | 12 -------- run_tests.sh | 8 ++++-- 6 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 Tests/chrome/agenciaclickone/IndexView.robot create mode 100644 Tests/firefox/agenciaclickone/ContactForm.robot create mode 100644 Tests/firefox/agenciaclickone/IndexView.robot delete mode 100644 docker-compose.yml diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index 5a8359f..0eb0fe6 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -9,6 +9,9 @@ on: - main schedule: - cron: "0 */3 * * *" +concurrency: + group: automation-${{ github.ref }} + cancel-in-progress: true permissions: id-token: write @@ -17,8 +20,12 @@ permissions: jobs: build-and-test: - name: Automation for agencia-clickone + name: Automation runs-on: ubuntu-latest + strategy: + matrix: + browser: [chrome, firefox] + client: [agenciaclickone] timeout-minutes: 5 steps: @@ -29,8 +36,7 @@ jobs: - name: Run automation tests run: | cd automation - ls -la - ./run_tests.sh -S ${{ env.INPUT_SRC }} + ./run_tests.sh -S ${{ env.INPUT_SRC }} -B ${{ matrix.browser }} -C ${{ matrix.client }} env: INPUT_SRC: automation - name: Upload test results diff --git a/Tests/chrome/agenciaclickone/IndexView.robot b/Tests/chrome/agenciaclickone/IndexView.robot new file mode 100644 index 0000000..e69de29 diff --git a/Tests/firefox/agenciaclickone/ContactForm.robot b/Tests/firefox/agenciaclickone/ContactForm.robot new file mode 100644 index 0000000..4a8c015 --- /dev/null +++ b/Tests/firefox/agenciaclickone/ContactForm.robot @@ -0,0 +1,28 @@ +*** Settings *** +Documentation Contact Form +Library SeleniumLibrary +Library Process + +*** Variables *** +${BROWSER} firefox + +*** Test Cases *** +Verify contact form for ClickOne + [Documentation] This test case verifies the contact form + [Tags] Functional + + ${firefox_options}= Create Firefox Options + Open Browser https://agenciaclickone.com/ ${BROWSER} options=${firefox_options} + Input Text //*[@id="form-field-name"] John Doe + Input Text //*[@id="form-field-email"] email@agenciaclickone.com + Input Text //*[@id="form-field-message"] 30000000 + Click Element //*[@id="form-field-Aceptolapoliticadeprivacidad"] + Click Button //*[@id="colophon"]/div/div/div/div/section[1]/div[2]/div/div[2]/div/div/div/div/form/div/div[5]/button + Wait Until Page Contains Gracias por contactarnos 15 + [Teardown] Close Browser + +*** Keywords *** +Create Firefox Options + ${options}= Evaluate sys.modules['selenium.webdriver'].FirefoxOptions() sys, selenium.webdriver + Call Method ${options} add_argument -headless + RETURN ${options} diff --git a/Tests/firefox/agenciaclickone/IndexView.robot b/Tests/firefox/agenciaclickone/IndexView.robot new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b31544a..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3' - -services: - nextjs-app: - container_name: clickone-automation - build: - context: . - dockerfile: Dockerfile - volumes: - - ./:/app - command: robot -d results /app/Tests - restart: always diff --git a/run_tests.sh b/run_tests.sh index 99d3039..73c5cc8 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash -while getopts "I:S:" flag +while getopts "I:S:B:C:" flag do case "${flag}" in + B) INPUT_BROWSER=${OPTARG};; + C) INPUT_CLIENT=${OPTARG};; S) INPUT_SRC=${OPTARG};; I) INSTALL_PACKAGES=${OPTARG};; *) echo "${OPTARG} is an invalid parameter";; @@ -10,6 +12,8 @@ do done SRC=${INPUT_SRC:=""} +BROWSER=${INPUT_BROWSER:=""} +CLIENT=${INPUT_CLIENT:=""} INSTALL_PACKAGES=true RUN_COMMAND="cd /app/$SRC" @@ -19,7 +23,7 @@ if [ "$INSTALL_PACKAGES" = true ] ; then RUN_COMMAND="${RUN_COMMAND}; ${UPDATE_PACKAGE_MANAGER_CMD}; ${INSTALLATION_PACKAGES_CMD}" fi -RUN_COMMAND="${RUN_COMMAND}; robot -d results Tests" +RUN_COMMAND="${RUN_COMMAND}; robot -d results Tests/${BROWSER}/${CLIENT}" # exit when any command fails set -e From 5c7fc72c367fe7e6d45d914f1de47293b4d747e3 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Sun, 16 Jun 2024 18:27:46 -0500 Subject: [PATCH 2/7] Configure firefox inside the container --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Dockerfile b/Dockerfile index cf7ff00..3192d2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,16 @@ RUN chown root:root /usr/bin/chromedriver RUN chmod +x /usr/bin/chromedriver RUN rm chromedriver-linux64.zip +RUN curl -L -o firefox-127.0.tar.bz2 "https://download.mozilla.org/?product=firefox-127.0&os=linux64&lang=en-US" +RUN tar xjf firefox-127.0.tar.bz2 -C /opt/ +RUN ln -s /opt/firefox/firefox /usr/local/bin/firefox + +# Download the latest version of geckodriver using curl +ENV GECKODRIVER_VERSION="v0.34.0" +RUN curl -L -o geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz "https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz" +RUN tar -xvzf geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz +RUN mv geckodriver /usr/local/bin/ + # Set environment variables ENV DISPLAY=:99 From 78e9efe192556b82b6030b6133ccd576f6da6f19 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Mon, 17 Jun 2024 06:45:01 -0500 Subject: [PATCH 3/7] Configure firefox inside the container --- .github/workflows/automation.yml | 6 ++-- .../firefox/agenciaclickone/ContactForm.robot | 28 ------------------- Tests/firefox/agenciaclickone/IndexView.robot | 0 3 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 Tests/firefox/agenciaclickone/ContactForm.robot delete mode 100644 Tests/firefox/agenciaclickone/IndexView.robot diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index 0eb0fe6..16facd9 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -8,7 +8,7 @@ on: branches: - main schedule: - - cron: "0 */3 * * *" + - cron: "0 */6 * * *" concurrency: group: automation-${{ github.ref }} cancel-in-progress: true @@ -24,8 +24,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - browser: [chrome, firefox] - client: [agenciaclickone] + browser: [chrome] + client: [agenciaclickone, fracturasyfracturas] timeout-minutes: 5 steps: diff --git a/Tests/firefox/agenciaclickone/ContactForm.robot b/Tests/firefox/agenciaclickone/ContactForm.robot deleted file mode 100644 index 4a8c015..0000000 --- a/Tests/firefox/agenciaclickone/ContactForm.robot +++ /dev/null @@ -1,28 +0,0 @@ -*** Settings *** -Documentation Contact Form -Library SeleniumLibrary -Library Process - -*** Variables *** -${BROWSER} firefox - -*** Test Cases *** -Verify contact form for ClickOne - [Documentation] This test case verifies the contact form - [Tags] Functional - - ${firefox_options}= Create Firefox Options - Open Browser https://agenciaclickone.com/ ${BROWSER} options=${firefox_options} - Input Text //*[@id="form-field-name"] John Doe - Input Text //*[@id="form-field-email"] email@agenciaclickone.com - Input Text //*[@id="form-field-message"] 30000000 - Click Element //*[@id="form-field-Aceptolapoliticadeprivacidad"] - Click Button //*[@id="colophon"]/div/div/div/div/section[1]/div[2]/div/div[2]/div/div/div/div/form/div/div[5]/button - Wait Until Page Contains Gracias por contactarnos 15 - [Teardown] Close Browser - -*** Keywords *** -Create Firefox Options - ${options}= Evaluate sys.modules['selenium.webdriver'].FirefoxOptions() sys, selenium.webdriver - Call Method ${options} add_argument -headless - RETURN ${options} diff --git a/Tests/firefox/agenciaclickone/IndexView.robot b/Tests/firefox/agenciaclickone/IndexView.robot deleted file mode 100644 index e69de29..0000000 From 0add066a6ab194c25841549c144dd227edd1d373 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Mon, 17 Jun 2024 09:54:02 -0500 Subject: [PATCH 4/7] Add test for contact form render --- Tests/chrome/agenciaclickone/IndexView.robot | 26 +++++++++++++++++++ .../fracturasyfracturas/IndexView.robot | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Tests/chrome/fracturasyfracturas/IndexView.robot diff --git a/Tests/chrome/agenciaclickone/IndexView.robot b/Tests/chrome/agenciaclickone/IndexView.robot index e69de29..af34906 100644 --- a/Tests/chrome/agenciaclickone/IndexView.robot +++ b/Tests/chrome/agenciaclickone/IndexView.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Contact Form +Library SeleniumLibrary +Library Process + +*** Variables *** +${BROWSER} chrome + +*** Test Cases *** +Verify contact form render + [Documentation] This test case verifies + [Tags] Functional + + ${chrome_options}= Create Chrome Options + Open Browser https://fracturasyfracturas.com.co/ ${BROWSER} options=${chrome_options} + Wait Until Element Is Visible xpath=//*[@id="colophon"]/div/div/div/div/section[1]/div[2]/div/div[2] 30s + [Teardown] Close Browser + +*** Keywords *** +Create Chrome Options + ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver + Call Method ${options} add_argument --headless + Call Method ${options} add_argument --disable-gpu + Call Method ${options} add_argument --no-sandbox + Call Method ${options} add_argument --disable-dev-shm-usage + RETURN ${options} diff --git a/Tests/chrome/fracturasyfracturas/IndexView.robot b/Tests/chrome/fracturasyfracturas/IndexView.robot new file mode 100644 index 0000000..4697281 --- /dev/null +++ b/Tests/chrome/fracturasyfracturas/IndexView.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Contact Form +Library SeleniumLibrary +Library Process + +*** Variables *** +${BROWSER} chrome + +*** Test Cases *** +Verify contact form render + [Documentation] This test case verifies + [Tags] Functional + + ${chrome_options}= Create Chrome Options + Open Browser https://fracturasyfracturas.com.co/ ${BROWSER} options=${chrome_options} + Wait Until Element Is Visible xpath=//*[@id="agenda"]/div/div[1]/div 30s + [Teardown] Close Browser + +*** Keywords *** +Create Chrome Options + ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver + Call Method ${options} add_argument --headless + Call Method ${options} add_argument --disable-gpu + Call Method ${options} add_argument --no-sandbox + Call Method ${options} add_argument --disable-dev-shm-usage + RETURN ${options} From d711cb47ea8585355be369c74a41e1ba846f8c55 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Mon, 17 Jun 2024 10:18:39 -0500 Subject: [PATCH 5/7] Add test for contact form render --- Tests/chrome/agenciaclickone/IndexView.robot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/chrome/agenciaclickone/IndexView.robot b/Tests/chrome/agenciaclickone/IndexView.robot index af34906..95c4bd1 100644 --- a/Tests/chrome/agenciaclickone/IndexView.robot +++ b/Tests/chrome/agenciaclickone/IndexView.robot @@ -8,12 +8,12 @@ ${BROWSER} chrome *** Test Cases *** Verify contact form render - [Documentation] This test case verifies + [Documentation] This test case verifies the contact form [Tags] Functional ${chrome_options}= Create Chrome Options Open Browser https://fracturasyfracturas.com.co/ ${BROWSER} options=${chrome_options} - Wait Until Element Is Visible xpath=//*[@id="colophon"]/div/div/div/div/section[1]/div[2]/div/div[2] 30s + Wait Until Page Contains Capta nuevas oportunidades comerciales en internet. 30 [Teardown] Close Browser *** Keywords *** From 65a4559bb31a30807393877845c588310abfdff8 Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Mon, 17 Jun 2024 10:20:41 -0500 Subject: [PATCH 6/7] Add test for contact form render --- Tests/chrome/agenciaclickone/IndexView.robot | 26 -------------------- 1 file changed, 26 deletions(-) delete mode 100644 Tests/chrome/agenciaclickone/IndexView.robot diff --git a/Tests/chrome/agenciaclickone/IndexView.robot b/Tests/chrome/agenciaclickone/IndexView.robot deleted file mode 100644 index 95c4bd1..0000000 --- a/Tests/chrome/agenciaclickone/IndexView.robot +++ /dev/null @@ -1,26 +0,0 @@ -*** Settings *** -Documentation Contact Form -Library SeleniumLibrary -Library Process - -*** Variables *** -${BROWSER} chrome - -*** Test Cases *** -Verify contact form render - [Documentation] This test case verifies the contact form - [Tags] Functional - - ${chrome_options}= Create Chrome Options - Open Browser https://fracturasyfracturas.com.co/ ${BROWSER} options=${chrome_options} - Wait Until Page Contains Capta nuevas oportunidades comerciales en internet. 30 - [Teardown] Close Browser - -*** Keywords *** -Create Chrome Options - ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver - Call Method ${options} add_argument --headless - Call Method ${options} add_argument --disable-gpu - Call Method ${options} add_argument --no-sandbox - Call Method ${options} add_argument --disable-dev-shm-usage - RETURN ${options} From 784088b2ef15bf58f5f856725cef7a736309c21c Mon Sep 17 00:00:00 2001 From: "Alejandro E. Rendon" Date: Mon, 17 Jun 2024 10:23:29 -0500 Subject: [PATCH 7/7] Add test for contact form render --- .github/workflows/automation.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml index 16facd9..7f907a1 100644 --- a/.github/workflows/automation.yml +++ b/.github/workflows/automation.yml @@ -39,8 +39,8 @@ jobs: ./run_tests.sh -S ${{ env.INPUT_SRC }} -B ${{ matrix.browser }} -C ${{ matrix.client }} env: INPUT_SRC: automation - - name: Upload test results - uses: actions/upload-artifact@v4 - with: - name: github-pages - path: automation/results/ + # - name: Upload test results + # uses: actions/upload-artifact@v4 + # with: + # name: github-pages + # path: automation/results/