Repository: SpectralSequences/sseq (language: python)

Issue:
Fix selenium test
There's a CI test that consistently fails right now, either by a timeout or a value error. This can't be caused by us, because commit ef6bc24 passed all tests, while the merged counterpart 16a0df9 failed


Discussion / hints:
Can you reproduce the error locally?

I've tried a few times but I'm having problems with spawning the webserver. I think that's just an error on my end though

Fix patch:
diff --git a/web_ext/sseq_gui/Makefile b/web_ext/sseq_gui/Makefile
index 4075c7011..553afce99 100644
--- a/web_ext/sseq_gui/Makefile
+++ b/web_ext/sseq_gui/Makefile
@@ -51,8 +51,8 @@ lint-selenium:
 	black --diff --check tests
 
 selenium:
-	python3 -m pytest tests --driver firefox
-	python3 -m pytest tests --driver chrome
+	python3 -m pytest -s tests --driver firefox
+	python3 -m pytest -s tests --driver chrome
 
 selenium-update:
 	python3 -m pytest tests --driver firefox --update


Test patch:
diff --git a/web_ext/sseq_gui/tests/test_s_2.py b/web_ext/sseq_gui/tests/test_s_2.py
index d894dc0ba..be279fb23 100644
--- a/web_ext/sseq_gui/tests/test_s_2.py
+++ b/web_ext/sseq_gui/tests/test_s_2.py
@@ -1,4 +1,6 @@
 import time
+from pathlib import Path
+
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.keys import Keys
 
@@ -119,17 +121,17 @@ def test_history(driver):
     driver.send_keys(Keys.ENTER)
 
     timeout = 0.1
+    save_path = Path(driver.tempdir) / "s_2.save"
     while True:
+        print(f"Waiting for {timeout} seconds")
         time.sleep(timeout)
-
-        try:
-            with open(f"{driver.tempdir}/s_2.save") as f:
-                driver.check_file("s_2.save", f.read())
+        file_contents = save_path.read_text() if save_path.exists() else None
+        if file_contents:
             break
-        except FileNotFoundError:
-            timeout *= 2
-            if timeout > 10:
-                raise TimeoutError
+        timeout *= 2
+        if timeout > 10:
+            raise TimeoutError
+    driver.check_file("s_2.save", file_contents)
 
     driver.go("/")
     driver.driver.find_element(By.ID, "history-upload").send_keys(