Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Automatic Screenshots of your Django web applic...
Search
Raphael Michel
October 25, 2017
Programming
270
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Automatic Screenshots of your Django web application with py.test and Selenium
Raphael Michel
October 25, 2017
More Decks by Raphael Michel
See All by Raphael Michel
Plug-in architectures for Python web applications
raphaelm
0
84
Data Internationalization in Django
raphaelm
2
560
Other Decks in Programming
See All in Programming
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
660
XHTMLが残したもの
yosuke_furukawa
PRO
1
380
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
620
Press start. Python's next generation.
willingc
PRO
3
300
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
120
Building an Out-of-Order CPU
latte72
0
640
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
1.5k
ALB ログから Trace を気合で繋げる技術
fohte
7
860
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
130
「AI時代、配布するPythonコードをどう守るか: 難読化の実験と判断軸」 #PyconJP2026
pkshadeck
PRO
2
150
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
960
AIエージェント時代のコードレビューを設計する
nogu66
5
2.5k
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Abbi's Birthday
coloredviolet
3
9.7k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
Designing Powerful Visuals for Engaging Learning
tmiket
1
530
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
490
Skip the Path - Find Your Career Trail
mkilby
1
220
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Become a Pro
speakerdeck
PRO
31
6.2k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
430
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Technical Leadership for Architectural Decision Making
baasie
3
550
Transcript
AUTOMATIC SCREENSHOTTING with Python, Django, py.test, and Selenium RAPHAEL MICHEL
MOTIVATION
INGREDIENTS
SELENIUM a remote control for your browser
CHROME HEADLESS $ chrome --headless
PY.TEST # content of test_sample.py def inc(x): return x +
1 def test_answer(): assert inc(3) == 5 $ py.test ======= test session starts ======== collected 1 item test_sample.py F ======= FAILURES ======== _______ test_answer ________ ... test_sample.py:5: AssertionError ======= 1 failed in 0.12 seconds ========
PY.TEST FIXTURES import pytest @pytest.fixture def smtp(): import smtplib return
smtplib.SMTP("smtp.gmail.com", 587, timeout=5) def test_ehlo(smtp): response, msg = smtp.ehlo() assert response == 250 assert 0 # for demo purposes
DJANGO pytest-django LiveServerTestCase
LET'S SET IT UP!
PYTEST.INI [pytest] DJANGO_SETTINGS_MODULE=pretix.testutils.settings python_functions = shot_* python_files = scene_* python_classess
= *Scene addopts =--driver Chrome
SCENES/CONFTEST.PY @pytest.fixture def user(): return User.objects.create_user( '
[email protected]
', 'john', fullname='John Doe'
)
SCENES/CONFTEST.PY @pytest.fixture def logged_in_client(live_server, selenium, user): selenium.get(live_server.url + '/control/login') selenium.implicitly_wait(10)
# Fill out name and password # Click button return selenium
SCENES/CONFTEST.PY @pytest.fixture def chrome_options(chrome_options): chrome_options.add_argument('headless') chrome_options.add_argument('window-size=1024x768')
AAAND… ACTION!
SCENES/SCENE_ORGA.PY @pytest.mark.django_db def shot_organizer_list(live_server, organizer, logged_in_client): logged_in_client.get( live_server.url + '/control/organizers/'
) screenshot(logged_in_client, 'organizer/list.png')
RUN IT $ py.test scenes … Results (45.80s): 9 passed
TADA!
pretix/pretix-screenshots
CONTACT ME! Raphael Michel
[email protected]
@_rami_ raphaelm pretix.eu
[email protected]
@pretixeu
pretix
MAY 23-27TH, 2018 HEIDELBERG, GERMANY 2018.DJANGOCON.EU