Skip to content

Commit 1cd4914

Browse files
committed
1 parent 72f65b7 commit 1cd4914

File tree

4 files changed

+91
-4
lines changed

4 files changed

+91
-4
lines changed

.github/workflows/robot-framework.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Robot Framework CI
2+
3+
# Borrowed code from:
4+
# https://piyathida-sanaoun01.medium.com/how-to-setup-ci-github-action-to-run-robot-framework-49028a404fee
5+
# https://github.com/laojala/robot_docker_demo/blob/master/.github/workflows/run_robot_framework_tests.yml
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
# Do not run tests if file README.md changes
12+
paths-ignore:
13+
- '**.md'
14+
pull_request:
15+
# Do not run tests if file README.md changes
16+
paths-ignore:
17+
- '**.md'
18+
schedule:
19+
# Run tests nightly at 2am
20+
- cron: '0 2 * * *'
21+
jobs:
22+
Run-Test:
23+
runs-on: ubuntu-20.04
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- uses: actions/cache@v4
28+
id: cache
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
32+
- name: Install pip dependencies
33+
run: |
34+
pip install --upgrade pip certifi urllib3
35+
pip install -r requirements.txt -r requirements-test.txt
36+
- name: Run Robot tests
37+
run: ADDITIONAL_ROBOT_ARGS="--variable=additional_chrome_options:--headless" ./run-robot-tests
38+
- name: Publish test results
39+
if: always()
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: robot-test-results
43+
path: tests/robot/output/

run-robot-tests

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
#!/bin/sh
22

3-
robot --outputdir=tests/robot/output --variable=app_url:http://localhost:8501 tests/robot/
3+
robot \
4+
--outputdir=tests/robot/output \
5+
--variable=app_url:http://localhost:8501 \
6+
${ADDITIONAL_ROBOT_ARGS} \
7+
tests/robot/

tests/robot/resources/app_keywords.robot

+36
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,48 @@ Library SeleniumLibrary
55
*** Variables ***
66

77
${st_keyup_iframe_locator} css:iframe[title="st_keyup.st_keyup"]
8+
${additional_chrome_options} ""
89

910
*** Keywords ***
1011

12+
Do Suite Setup
13+
${process} = Start Process
14+
... streamlit run streamlit_app.py
15+
... --server.port 8501
16+
... --server.headless true
17+
... --browser.gatherUsageStats false
18+
Log PID: ${process.pid}
19+
VAR ${PROCESS} ${process} scope=SUITE
20+
21+
Do Suite Teardown
22+
Log PID: ${PROCESS.pid}
23+
${result} = Terminate Process ${PROCESS}
24+
Log Terminate process result: ${result}
25+
1126
Input text into st_keyup
1227
[Arguments] ${text}
1328
Wait until element is visible ${st_keyup_iframe_locator}
1429
Select frame ${st_keyup_iframe_locator}
1530
Input text css:input[type="text"] ${text}
1631
Unselect frame
32+
33+
Open URL
34+
[Arguments] ${url}
35+
Create Chrome WebDriver
36+
Maximize Browser Window
37+
Go To ${url}
38+
Wait For Condition return document.readyState == "complete"
39+
Wait Until Page Does Not Contain Running...
40+
Sleep 1 second
41+
${result}= Run Keyword And Return Status Page Should Not Contain Traceback
42+
# Log To Console ${result}
43+
IF ${result} != True
44+
${error_text}= Get Text css:.message
45+
Fail Page should not contain "Traceback". Error: ${error_text}
46+
END
47+
48+
Create Chrome WebDriver
49+
${chrome_options} = Evaluate selenium.webdriver.ChromeOptions()
50+
# Call Method ${chrome_options} add_argument --no-sandbox
51+
Call Method ${chrome_options} add_argument ${additional_chrome_options}
52+
Create WebDriver Chrome options=${chrome_options}

tests/robot/test_cases.robot

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
*** Settings ***
22

3-
Resource resources/app_keywords.robot
3+
Resource resources/app_keywords.robot
4+
Library Process
5+
Suite Setup Do Suite Setup
6+
Suite Teardown Do Suite Teardown
47

58
*** Variables ***
69

7-
${app_url} http://localhost:8501
10+
${app_url} http://localhost:8501
811

912
*** Test Cases ***
1013

1114
Interact with st_keyup
12-
Open browser ${app_url} Chrome
15+
Sleep 2s
16+
Open URL ${app_url}
1317
Input text into st_keyup adjunta
1418
Wait until page contains URB San Joaquin
1519
Wait until page contains Jard De Adjuntas

0 commit comments

Comments
 (0)