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
New "Type" system on PicoRuby
pocke
1
830
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
260
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
270
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
690
dRuby over BLE
makicamel
2
330
A2UI という光を覗いてみる
satohjohn
1
130
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
2
660
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
150
Lessons from Spec-Driven Development
simas
PRO
0
170
スマートグラスで並列バイブコーディング
hyshu
0
120
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
Oxlintのカスタムルールの現況
syumai
6
1.1k
Featured
See All Featured
Accessibility Awareness
sabderemane
1
140
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
410
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
71
40k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
330
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
GitHub's CSS Performance
jonrohan
1033
470k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
440
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
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