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 がコードを書く時代における新卒エンジニアの仕事風景 (2026) / New Graduate Engineers in the Era of AI Coding (2026)
sushichan044
0
200
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
1
180
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
230
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.2k
自作OSでスライド発表する
uyuki234
1
3.6k
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.6k
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
170
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.9k
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
210
スマートグラスで並列バイブコーディング
hyshu
0
280
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6k
KATA
mclloyd
PRO
35
15k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
440
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
180
What's in a price? How to price your products and services
michaelherold
247
13k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
Google's AI Overviews - The New Search
badams
0
1.1k
The untapped power of vector embeddings
frankvandijk
2
1.8k
Building an army of robots
kneath
306
46k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
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