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
Automatisierte Browser-Tests mit gocept.selenium
Search
wosc
October 05, 2011
Programming
290
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Automatisierte Browser-Tests mit gocept.selenium
wosc
October 05, 2011
More Decks by wosc
See All by wosc
Keep a changelog
wosc
0
350
werkzeugkiste.pdf
wosc
0
190
Ideenklau erwünscht: Konzepte aus der Zope-Welt
wosc
2
320
Other Decks in Programming
See All in Programming
AIで効率化できた業務・日常
ochtum
0
160
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
290
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
340
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
110
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
210
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
780
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
6
920
なぜ関数型プログラミングで「型」と「証明」が語られるのか #fp_matsuri
kajitack
0
220
Vite+ Unified Toolchain for the Web
naokihaba
0
410
dRuby over BLE
makicamel
2
400
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
170
Featured
See All Featured
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
320
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.7k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
Designing for humans not robots
tammielis
254
26k
Building AI with AI
inesmontani
PRO
1
1.1k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
410
Color Theory Basics | Prateek | Gurzu
gurzu
0
380
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
180
Un-Boring Meetings
codingconduct
0
330
KATA
mclloyd
PRO
35
15k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Transcript
Automatisierte Browser-Tests mit (gocept.)Selenium Wolfgang Schnerring gmbh & co. kg
PyCon DE 2011, Leipzig Wolfgang Schnerring Selenium 07.10.2011 1 / 19
None
Einführung Web 2.0 und JavaScript Wolfgang Schnerring Selenium 07.10.2011 3
/ 19
Einführung Browser-Fernsteuerung Wolfgang Schnerring Selenium 07.10.2011 4 / 19
Selenium Architektur nach: http://seleniumhq.org/projects/remote-control/ Wolfgang Schnerring Selenium 07.10.2011 5 /
19
Selenium Funktionsumfang Wolfgang Schnerring Selenium 07.10.2011 6 / 19
Selenium API open http://www.google.de/ type name=q zope waitForVisible id=suggestions assertText
//div[@id=’suggestions’])/ul/li[2] *fisch Wolfgang Schnerring Selenium 07.10.2011 7 / 19
Selenium API open http://www.google.de/ type name=q zope waitForVisible id=suggestions assertText
//div[@id=’suggestions’])/ul/li[2] *fisch s = selenium.selenium(server, port, ’∗firefox’) s.start() s.open(’http://www.google.de/’) s.type(’name=q’, ’zope’) # won’t work because of asynchronity! assertTrue(s.is_visible(’id=suggestions’))) assertEqual(s.get_text(’//div[@id="suggestions"])/ul/li[2]’, ’fisch’) Wolfgang Schnerring Selenium 07.10.2011 7 / 19
None
gocept.selenium Beispielcode class AutocompleteTest(gocept.selenium.wsgi.TestCase): def test_search_field_should_show_suggestions(self): s = self.selenium s.open(’http://www.google.de/’)
s.type(’name=q’, ’zope’) s.waitForVisible(’id=suggestions’)) s.assertText(’//div[@id="suggestions"])/ul/li[2]’, ’∗fisch’) Wolfgang Schnerring Selenium 07.10.2011 9 / 19
gocept.selenium Befehlstypen Aktionen click(locator), type(), dragAndDrop() Abfragen getText(locator), getSelectedValues(), getHeight()
Assertions assertText(locator, pattern), assertElementPresent() Asynchron waitForElementPresent(), waitForXpathCount() Wolfgang Schnerring Selenium 07.10.2011 10 / 19
gocept.selenium Locators Element-ID getText(’id=navigation’) CSS getText(’css=div.navigation li a’) XPath getText(’//div[@id="suggestions"])/ul/li[2]’)
Javascript getText(’document.forms[’myForm’].myDropdown’) Wolfgang Schnerring Selenium 07.10.2011 11 / 19
Abstraktion click(’id=menu1’) waitForElementPresent(’css=div.lightbox’) waitForVisible(’css=div.lightbox’) click(’css=a.close’) waitForElementNotPresent(’css=div.lightbox’) Wolfgang Schnerring Selenium 07.10.2011
12 / 19
Abstraktion click(’id=menu1’) waitForElementPresent(’css=div.lightbox’) waitForVisible(’css=div.lightbox’) click(’css=a.close’) waitForElementNotPresent(’css=div.lightbox’) click(’id=menu1’) assertLightboxOpens() click(’css=a.close’) assertLightboxCloses()
Wolfgang Schnerring Selenium 07.10.2011 12 / 19
None
Test-Integration Setup Wolfgang Schnerring Selenium 07.10.2011 14 / 19
Test-Integration Layer class Layer(object): __bases__ = (OTHER_LAYER,) def setUp(self): #
[start browser] def tearDown(self): # [kill browser] def testSetUp(self): def testTearDown(self): Wolfgang Schnerring Selenium 07.10.2011 15 / 19
Test-Integration einfacher mit zope.testrunner from my.package.main import my_wsgi_callable class AutocompleteTest(gocept.selenium.wsgi.TestCase):
layer = gocept.selenium.wsgi.Layer(my_wsgi_callable) def test_search_field_should_show_suggestions(self): s = self.selenium s.open(’http://%s:%s/foo’ % (self.layer.host, self.layer.port) s.assertTextPresent(’Hello, world!’) Wolfgang Schnerring Selenium 07.10.2011 16 / 19
None
Ausblick & Ressourcen Selenium-2.x (WebDriver-API) JsTestDriver http://seleniumhq.org http://release.seleniumhq.org/selenium-core/1.0/reference.html http://pypi.python.org/pypi/gocept.selenium Wolfgang
Schnerring Selenium 07.10.2011 18 / 19
Wir suchen Mitarbeiter in Halle! Softwareentwicklung Web Python TDD Systemadministration
Gentoo/KVM Puppet Nagios Bei Interesse: mich ansprechen oder
[email protected]
Wolfgang Schnerring Selenium 07.10.2011 19 / 19