How My Comic Book Obsession Birthed a New Functional Testing Tool

389 views
281 views

Published on

Introducing PunkyBrowster, a programmatic web browser that uses a real web browser.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
389
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How My Comic Book Obsession Birthed a New Functional Testing Tool

  1. 1. How My Comic BookObsession Birthed a New Functional Testing Tool Feihong HsuTesting in Python Birds of a Feather March 12, 2011
  2. 2. I like comics
  3. 3. I like studying Chinese 我喜欢学中文 我喜歡學中文
  4. 4. These are two tastes that go great together!
  5. 5. Especially whenyou find a realgem like this:
  6. 6. Problem: Chinese comics portals loadslowly and have poor usabilitySolution: Write a web scraping tool tobatch download images, so I canbe a proper Apple fanboy and readcomics on my iPad
  7. 7. First approach: urllib2 + lxml.htmlVerdict: Total fail, couldnt handleJavaScript and cookies
  8. 8. Second approach: XULRunnerVerdict: Asynchronous logic waspainful, Python integration would nothave been trivial
  9. 9. Third approach: spynnerVerdict: Not bad! But... some sitesdont load. Why?
  10. 10. Fourth approach: Make spynnerdumberVerdict: Frickin awesome
  11. 11. Coincidence: At Leapfrog, we neededa better way to test JavaScriptbehavior on our sitesResult: Leapfrog subsidizes mycomic book addiction
  12. 12. Over time, we added some nice stuffto our spynner fork- Ability to ignore SSL errors- Form manipulation methods- Screen capture (consistently-sizedimages)- Other stuff that I cant remember
  13. 13. Question: Hey Feihong, where can I getthis sexy library?Answer: Nowhere, Im too busyreading comics to open source it
  14. 14. Real answer: Were working onopen sourcing it, but we ran intosome blocks(Cast sidelong glance at Terry)
  15. 15. However, we are NOTsoliciting suggestions for a name. We have thePERFECT name already.
  16. 16. PunkyBrowster
  17. 17. Some basic usage
  18. 18. from punky import Browsterbrowser = Browster(auto_load_images=True)browser.create_webview(show=True)browser.load(http://www.duckduckgo.com/)browser.fill(input#hfih, How do I de-pube-ify waterless urinals?)browser.submit(form#hfh, wait_load=True)for element in browser.all(#r12 > div): print unicode(element.toPlainText())
  19. 19. Random note: Inever want to have the need to see a urologist. But if I do, I hope hes wearing a badge like this:
  20. 20. I am done

×