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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
350
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
750
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.4k
AutonomyとControlのあいだ:Graflowで記述するAIエージェント協調
myui
0
120
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
210
Agentic UI
manfredsteyer
PRO
0
140
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.6k
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
240
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
690
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
450
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
110
Featured
See All Featured
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
A Tale of Four Properties
chriscoyier
163
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
How to Talk to Developers About Accessibility
jct
2
230
Design in an AI World
tapps
1
240
Rails Girls Zürich Keynote
gr2m
96
14k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
430
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
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