Skip to content

Commit 7a582a1

Browse files
author
Obada Haddad
committed
change waiting for finished logic
1 parent e39a18f commit 7a582a1

1 file changed

Lines changed: 35 additions & 46 deletions

File tree

playwrightPython/test_submission.py

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ def browser_context_args(browser_context_args):
1313
return browser_context_args
1414

1515

16-
def wait_for_finished(page, time_out):
17-
try:
18-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=time_out)
19-
return True
20-
except:
21-
return False
22-
23-
2416
def test_submission_v2_multiTaskFactSheet(page: Page) -> None:
2517
page.goto("/")
2618
page.get_by_role("link", name=" Benchmarks/Competitions").click()
@@ -41,13 +33,12 @@ def test_submission_v2_multiTaskFactSheet(page: Page) -> None:
4133
file_chooser.set_files("test_files/submissions/submission.zip")
4234
expect(page.locator('.ui.indicating')).to_be_visible()
4335
expect(page.locator('.ui.indicating')).not_to_be_visible()
44-
# Reload the page until the finished status is visible or the count is reached
45-
count = 0
46-
while not wait_for_finished(page, 10000) and count < 5:
36+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
37+
try:
38+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=35000)
39+
except:
4740
page.reload()
48-
count += 1
49-
page.reload()
50-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
41+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)
5142

5243

5344
def test_submission_v2_multiTask(page: Page) -> None:
@@ -66,17 +57,15 @@ def test_submission_v2_multiTask(page: Page) -> None:
6657
file_chooser.set_files("test_files/submissions/submission.zip")
6758
expect(page.locator('.ui.indicating')).to_be_visible()
6859
expect(page.locator('.ui.indicating')).not_to_be_visible()
69-
# Reload the page until the finished status is visible or the count is reached
70-
count = 0
71-
while not wait_for_finished(page, 10000) and count < 5:
60+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
61+
try:
62+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=35000)
63+
except:
7264
page.reload()
73-
count += 1
74-
page.reload()
75-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
65+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)
7666

7767

7868
def test_submission_basic(page: Page) -> None:
79-
page.set_default_timeout(300000)
8069
page.goto("/")
8170
page.get_by_role("link", name=" Benchmarks/Competitions").click()
8271
page.get_by_role("link", name=" Upload").click()
@@ -92,12 +81,12 @@ def test_submission_basic(page: Page) -> None:
9281
file_chooser.set_files("test_files/submissions/submission.zip")
9382
expect(page.locator('.ui.indicating')).to_be_visible()
9483
expect(page.locator('.ui.indicating')).not_to_be_visible()
95-
# Reload the page until the finished status is visible or the count is reached
96-
count = 0
97-
while not wait_for_finished(page, 5000) and count < 5:
84+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
85+
try:
86+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=25000)
87+
except:
9888
page.reload()
99-
count += 1
100-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
89+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)
10190

10291

10392
def test_submission_irisV15_code(page: Page) -> None:
@@ -116,12 +105,12 @@ def test_submission_irisV15_code(page: Page) -> None:
116105
file_chooser.set_files("test_files/submissions/submission_15_iris_code.zip")
117106
expect(page.locator('.ui.indicating')).to_be_visible()
118107
expect(page.locator('.ui.indicating')).not_to_be_visible()
119-
# Reload the page until the finished status is visible or the count is reached
120-
count = 0
121-
while not wait_for_finished(page, 5000) and count < 5:
108+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
109+
try:
110+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=25000)
111+
except:
122112
page.reload()
123-
count += 1
124-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
113+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)
125114

126115

127116
def test_submission_irisV15_result(page: Page) -> None:
@@ -140,12 +129,12 @@ def test_submission_irisV15_result(page: Page) -> None:
140129
file_chooser.set_files("test_files/submissions/submission_15_iris_result.zip")
141130
expect(page.locator('.ui.indicating')).to_be_visible()
142131
expect(page.locator('.ui.indicating')).not_to_be_visible()
143-
# Reload the page until the finished status is visible or the count is reached
144-
count = 0
145-
while not wait_for_finished(page, 5000) and count < 5:
132+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
133+
try:
134+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=25000)
135+
except:
146136
page.reload()
147-
count += 1
148-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
137+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)
149138

150139

151140
def test_submission_v15(page: Page) -> None:
@@ -164,12 +153,12 @@ def test_submission_v15(page: Page) -> None:
164153
file_chooser.set_files("test_files/submissions/submission_15.zip")
165154
expect(page.locator('.ui.indicating')).to_be_visible()
166155
expect(page.locator('.ui.indicating')).not_to_be_visible()
167-
# Reload the page until the finished status is visible or the count is reached
168-
count = 0
169-
while not wait_for_finished(page, 5000) and count < 5:
156+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
157+
try:
158+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=25000)
159+
except:
170160
page.reload()
171-
count += 1
172-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
161+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)
173162

174163

175164
def test_submission_v18(page: Page) -> None:
@@ -188,9 +177,9 @@ def test_submission_v18(page: Page) -> None:
188177
file_chooser.set_files("test_files/submissions/submission_18.zip")
189178
expect(page.locator('.ui.indicating')).to_be_visible()
190179
expect(page.locator('.ui.indicating')).not_to_be_visible()
191-
# Reload the page until the finished status is visible or the count is reached
192-
count = 0
193-
while not wait_for_finished(page, 5000) and count < 5:
180+
# Wait for Finished to show. If it does not, catch the error and reload the page in case the page didn't update automatically
181+
try:
182+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=25000)
183+
except:
194184
page.reload()
195-
count += 1
196-
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=1)
185+
expect(page.get_by_role("cell", name="Finished")).to_be_visible(timeout=2000)

0 commit comments

Comments
 (0)