Skip to content

Commit 5d709b4

Browse files
committed
Update screenshot script for changes to make example.
It now waits for make example to process the db migrations before selenium browses out. It also handles toolbar already being open in the case of existing cookies.
1 parent f4c263a commit 5d709b4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

example/screenshot.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import signal
55
import subprocess
6+
from time import sleep
67

78
from selenium.webdriver.common.keys import Keys
89
from selenium.webdriver.support import expected_conditions as EC
@@ -33,7 +34,10 @@ def create_webdriver(browser, headless):
3334

3435

3536
def example_server():
36-
return subprocess.Popen(["make", "example"])
37+
proc = subprocess.Popen(["make", "example"])
38+
# `make example` runs a few things before runserver.
39+
sleep(2)
40+
return proc
3741

3842

3943
def set_viewport_size(selenium, width, height):
@@ -67,12 +71,15 @@ def main():
6771
submit_form(selenium, {"username": os.environ["USER"], "password": "p"})
6872

6973
selenium.get("http://localhost:8000/admin/auth/user/")
70-
# Close the admin sidebar.
71-
el = selenium.find_element_by_id("toggle-nav-sidebar")
72-
el.click()
74+
# Check if SQL Panel is already visible:
75+
sql_panel = selenium.find_element_by_id("djdt-SQLPanel")
76+
if not sql_panel:
77+
# Open the admin sidebar.
78+
el = selenium.find_element_by_id("djDebugToolbarHandle")
79+
el.click()
80+
sql_panel = selenium.find_element_by_id("djdt-SQLPanel")
7381
# Open the SQL panel.
74-
el = selenium.find_element_by_id("djdt-SQLPanel")
75-
el.click()
82+
sql_panel.click()
7683

7784
selenium.save_screenshot(args.outfile)
7885
finally:

0 commit comments

Comments
 (0)