Commit c97c1b9c authored by Marc Egger's avatar Marc Egger
Browse files

selenium test, small fix

parent 0f243da2
Pipeline #3850 failed with stages
in 2 minutes and 26 seconds
......@@ -353,28 +353,24 @@ class QfqSeleniumTestCase(unittest.TestCase):
"""
this function uploads a generated file from the given
arguments size and suffix. This file is uploaded to the
input with the given data reference.
input field with the given data reference.
"""
# stores the tmp dir name
# create temp directory
tmp_dir = "tmp"
# checks if the tmp dir doesn't already exist
if not os.path.exists(tmp_dir):
# creates tmp dir if it doesn't exist
os.makedirs(tmp_dir)
# loops through all files in the tmp directory
# remove old temp files
for f in glob.glob(tmp_dir + "/*." + suffix):
# removes each file (old test files)
os.remove(f)
# stores the path for the file
# create random file
file_path = os.getcwd() + "/" + tmp_dir + "/" + file_name + "." + suffix
# opens the file from the file path (creates the file)
with open(file_path, "w") as f:
# writes some random text to the file with the given size
f.write(self.qfq_generate_random_string(size))
# uploads the created file
# fill path into upload field
self.qfq_get_element_by_data_ref(data_reference).send_keys(file_path)
......
#!/bin/bash
# run a single test function. e.g. "test_basic_functionality.TestBasicFunctionality.test_qfq_form_switch_pill"
TEST_FUNCTION="test_basic_functionality.TestBasicFunctionality.test_qfq_form_switch_pill" # NOTE: make sure there are no trailing spaces!
TEST_FUNCTION="test_basic_functionality.TestBasicFunctionality.test_qfq_valid_file_upload" # NOTE: make sure there are no trailing spaces!
export SELENIUM_URL="https://webwork16.math.uzh.ch/megger/qfq/typo3conf/ext/qfq/NoT3Page"
export SELENIUM_BROWSER="chrome"
......
......@@ -203,6 +203,7 @@ class TestBasicFunctionality(qfqselenium.QfqSeleniumTestCase):
# upload valid file
s.qfq_open_pill(s.pill2_text)
s.qfq_upload_file(s.file_upload_ref, unique_file_name, "txt", 32)
s.qfq_wait(1)
# save + close
s.qfq_click_save_form_button()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment