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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Raphael Michel
October 25, 2017
Programming
260
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
76
Data Internationalization in Django
raphaelm
2
550
Other Decks in Programming
See All in Programming
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.5k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
220
さぁV100、メモリをお食べ・・・
nilpe
0
130
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.5k
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
620
AIエージェントの隔離技術の徹底比較
kawayu
0
470
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
450
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.5k
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
4.5k
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
310
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
230
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
96
14k
Everyday Curiosity
cassininazir
0
220
Speed Design
sergeychernyshev
33
1.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Believing is Seeing
oripsolob
1
140
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
380
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
560
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
GraphQLとの向き合い方2022年版
quramy
50
15k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
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