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
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
320
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.2k
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
250
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
200
AIで効率化できた業務・日常
ochtum
0
120
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
510
The NotImplementedError Problem in Ruby
koic
1
660
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
550
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
450
JavaDoc 再入門
nagise
0
310
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
230
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
720
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
430
Test your architecture with Archunit
thirion
1
2.3k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
ラッコキーワード サービス紹介資料
rakko
1
3.6M
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Deep Space Network (abreviated)
tonyrice
0
170
A designer walks into a library…
pauljervisheath
211
24k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
420
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