Skip to content

Commit e89f12a

Browse files
committed
🪵 check browser logs in selenium tests
1 parent d1c6046 commit e89f12a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tests/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,29 @@ def driver():
4444
from seleniumwire import webdriver
4545
from webdriver_manager.chrome import ChromeDriverManager, ChromeType
4646
from selenium.webdriver.chrome.options import Options
47+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
4748

4849
import time
4950
time.sleep(1)
5051

5152
options = Options()
53+
d = DesiredCapabilities.CHROME
54+
d['goog:loggingPrefs'] = {'browser': 'ALL'}
5255
if not TESTING_LOCAL:
5356
if headless:
5457
options.add_argument("--headless")
5558
# options.add_argument("--no=sandbox")
5659
driver = webdriver.Chrome(
5760
ChromeDriverManager(chrome_type=ChromeType.GOOGLE).install(),
5861
options=options,
62+
desired_capabilities=d,
5963
)
6064
else:
6165
options.add_argument("--remote-debugging-port=9222")
6266
driver = webdriver.Chrome(
6367
options=options,
64-
# executable_path="/home/jonas/git/gIDLaB/plotly-dynamic-resampling/chromedriver",
68+
executable_path="/home/jeroen/chromedriver",
69+
desired_capabilities=d,
6570
)
6671
# driver = webdriver.Firefox(executable_path='/home/jonas/git/gIDLaB/plotly-dynamic-resampling/geckodriver')
6772
return driver

tests/test_figure_resampler_selenium.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_multiple_tz(driver, multiple_tz_figure):
6969
assert len(autoscale_requests) == 1
7070
assert autoscale_requests[0].response.status_code == 204
7171

72+
assert driver.get_log("browser") == [] # Check no errors in the browser
7273
except Exception as e:
7374
raise e
7475
finally:
@@ -173,6 +174,7 @@ def test_basic_example_gui(driver, example_figure):
173174
n_updated_traces=5,
174175
)
175176

177+
assert driver.get_log("browser") == [] # Check no errors in the browser
176178
except Exception as e:
177179
raise e
178180
finally:
@@ -280,6 +282,7 @@ def test_basic_example_gui_existing(driver, example_figure_fig):
280282
n_updated_traces=5,
281283
)
282284

285+
assert driver.get_log("browser") == [] # Check no errors in the browser
283286
except Exception as e:
284287
raise e
285288
finally:
@@ -382,6 +385,8 @@ def test_gsr_gui(driver, gsr_figure):
382385

383386
fr.reset_axes()
384387
time.sleep(0.2)
388+
389+
assert driver.get_log("browser") == [] # Check no errors in the browser
385390
except Exception as e:
386391
raise e
387392
finally:
@@ -456,6 +461,7 @@ def test_cat_gui(driver, cat_series_box_hist_figure):
456461
n_updated_traces=1,
457462
)
458463

464+
assert driver.get_log("browser") == [] # Check no errors in the browser
459465
except Exception as e:
460466
raise e
461467
finally:
@@ -531,6 +537,7 @@ def test_shared_hover_gui(driver, shared_hover_figure):
531537
assert len(autoscale_requests) == 1
532538
assert autoscale_requests[0].response.status_code == 204
533539

540+
assert driver.get_log("browser") == [] # Check no errors in the browser
534541
except Exception as e:
535542
raise e
536543
finally:
@@ -603,6 +610,7 @@ def test_multi_trace_go_figure(driver, multi_trace_go_figure):
603610
assert len(autoscale_requests) == 1
604611
assert autoscale_requests[0].response.status_code == 204
605612

613+
assert driver.get_log("browser") == [] # Check no errors in the browser
606614
except Exception as e:
607615
raise e
608616
finally:

0 commit comments

Comments
 (0)