Skip to content

Commit 3442f4f

Browse files
committed
1 parent 72f65b7 commit 3442f4f

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed
Lines changed: 43 additions & 0 deletions
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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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

@@ -14,3 +15,24 @@ Input text into st_keyup
1415
Select frame ${st_keyup_iframe_locator}
1516
Input text css:input[type="text"] ${text}
1617
Unselect frame
18+
19+
Open URL
20+
[Arguments] ${url}
21+
Create Chrome WebDriver
22+
Maximize Browser Window
23+
Go To ${url}
24+
Wait For Condition return document.readyState == "complete"
25+
Wait Until Page Does Not Contain Running...
26+
Sleep 1 second
27+
${result}= Run Keyword And Return Status Page Should Not Contain Traceback
28+
# Log To Console ${result}
29+
IF ${result} != True
30+
${error_text}= Get Text css:.message
31+
Fail Page should not contain "Traceback". Error: ${error_text}
32+
END
33+
34+
Create Chrome WebDriver
35+
${chrome_options} = Evaluate selenium.webdriver.ChromeOptions()
36+
# Call Method ${chrome_options} add_argument --no-sandbox
37+
Call Method ${chrome_options} add_argument ${additional_chrome_options}
38+
Create WebDriver Chrome options=${chrome_options}

tests/robot/test_cases.robot

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Settings ***
22

33
Resource resources/app_keywords.robot
4+
Library Process
45

56
*** Variables ***
67

@@ -9,8 +10,13 @@ ${app_url} http://localhost:8501
910
*** Test Cases ***
1011

1112
Interact with st_keyup
12-
Open browser ${app_url} Chrome
13+
${process} = Start Process streamlit run streamlit_app.py --server.port 8501 --server.headless true --browser.gatherUsageStats false
14+
Log PID: ${process.pid}
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
1620
Wait until page contains Colinas Del Gigante
21+
${result} = Terminate Process ${process}
22+
Log Terminate process result: ${result}

0 commit comments

Comments
 (0)