-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
# More GitHub Actions for Azure: https://github.com/Azure/actions | ||
|
||
name: test Kobo submission | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: 'ubuntu-latest' | ||
defaults: | ||
run: | ||
working-directory: ./app | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
architecture: 'x64' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install selenium click | ||
- name: Run tests | ||
run: | | ||
python test_submission.py --form ${{ secrets.KOBO_TEST_FORM }} --url ${{ secrets.KOBO_TEST_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ coverage.xml | |
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
logs/ | ||
|
||
# Translations | ||
*.mo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.firefox.options import Options | ||
from selenium.webdriver.common.by import By | ||
import time | ||
import click | ||
import random | ||
import string | ||
|
||
|
||
@click.command() | ||
@click.option("--form", help="Kobo form ID") | ||
@click.option("--url", help="Kobo form URL") | ||
def test(form, url): | ||
options = Options() | ||
options.add_argument("-headless") | ||
driver = webdriver.Firefox(options=options) | ||
driver.get(url) | ||
time.sleep(5) | ||
|
||
questions = { | ||
"firstname": "".join(random.choices(string.ascii_uppercase, k=6)), | ||
"lastname": "".join(random.choices(string.ascii_uppercase, k=6)), | ||
} | ||
|
||
for question, answer in questions.items(): | ||
text_input = driver.find_element( | ||
By.XPATH, f"//input[@name='/{form}/{question}']" | ||
) | ||
text_input.send_keys(answer) | ||
|
||
search_button = driver.find_element(By.ID, "submit-form") | ||
search_button.click() | ||
|
||
driver.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
test() |