Commit 3fe3ef2c authored by Jérome Perrin's avatar Jérome Perrin

ERP5TypeFunctionalTestCase: wait for test table to be populated

It happens, for example with erp5_officejs_ui_test:testFunctionalOfficeJSPyodideNotebook
on test_result_module/20210615-CDADEC14/183 that the test is considered as
not running, because the test result table was not populated in time.

Add an explicit wait to prevent such problems.
parent 8185c048
...@@ -258,13 +258,25 @@ class FunctionalTestRunner: ...@@ -258,13 +258,25 @@ class FunctionalTestRunner:
))) )))
# XXX No idea how to wait for the iframe content to be loaded # XXX No idea how to wait for the iframe content to be loaded
time.sleep(5) time.sleep(5)
# Count number of test to be executed # Count number of tests to be executed
test_count = browser.execute_script( test_count = browser.execute_script(
"return document.getElementById('testSuiteFrame').contentDocument.querySelector('tbody').children.length" "return document.getElementById('testSuiteFrame').contentDocument.querySelector('tbody').children.length"
) - 1 ) - 1
# Wait for tests to end
WebDriverWait(browser, self.timeout).until(EC.presence_of_element_located(( WebDriverWait(browser, self.timeout).until(EC.presence_of_element_located((
By.XPATH, '//td[@id="testRuns" and contains(text(), "%i")]' % test_count By.XPATH, '//td[@id="testRuns" and contains(text(), "%i")]' % test_count
))) )))
# At the end of each test, updateSuiteWithResultOfPreviousTest updates
# testSuiteFrame iframe with hidden div containing the test results table.
# We will inspect these tables to know which tests have failed. First we
# need to wait a bit more, because at the end of test ( testComplete ),
# updateSuiteWithResultOfPreviousTest is called by setTimeout. We want to
# wait for the last test (which is the last td) result table to be present
browser.switch_to_frame('testSuiteFrame')
WebDriverWait(browser, 10).until(EC.presence_of_element_located((
By.XPATH, '//table/tbody/tr/td[last()]//table'
)))
browser.switch_to_default_content()
self.execution_duration = round(time.time() - start_time, 2) self.execution_duration = round(time.time() - start_time, 2)
html_parser = etree.HTMLParser(recover=True) html_parser = etree.HTMLParser(recover=True)
iframe = etree.fromstring( iframe = etree.fromstring(
......
Markdown is supported
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