Tips                                        A Poem By                                      Aaron Silverman                ...
XPATH                             <Locating elements by XPATH is one of the deadly selenium sinsIt is even worse, and slow...
Complicated Page With Dynamic Content                                         ID = my_parent                              ...
Issue                       Threat Level                 Solution                Velociraptor                3            ...
Complicated Page With Dynamic Content         Name:            Robert’) DROP TABLE students;--         Quest:         Favo...
Complicated Page With Dynamic Content                                                                                   Am...
Oh no!        Complicated Page With Dynamic ContentSelenium tries its best, but in some cases like a deer in headlights it...
Testing Code                                                  The test did this                                           ...
Testing Code                             Click                             Screenshot                                     ...
Upcoming SlideShare
Loading in …5
×

Seconf2011 - annotated lightning talk - a smattering of selenium tips

1,245
-1

Published on

Annotated slides of the lightning talk I gave at the 2011 selenium conference. The transcript of the poem is included in boxes at the bottom of each slide. The audio/video can be seen on YouTube: http://www.youtube.com/watch?v=5HmvzaLodL0

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,245
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Seconf2011 - annotated lightning talk - a smattering of selenium tips

  1. 1. Tips A Poem By Aaron Silverman YouTube Video: http://www.youtube.com/watch?v=5HmvzaLodL0 (0:10 – 3:10)Like Patrick kindly did last evening, I want to take advantage of being on the soapbox and share some tips I found useful andthat I think will help you all out. So, borrowing from the official selenium blog title, I present you a smattering of seleniumtips: A poem about lessons learned.
  2. 2. XPATH <Locating elements by XPATH is one of the deadly selenium sinsIt is even worse, and slower, than using Windows MEBut if you need to traverse up and down the DOM you cannot winYou will have to use XPATH, but proceed carefully!
  3. 3. Complicated Page With Dynamic Content ID = my_parent BUTTON #my_parent .orange_starWhat we found works best is to use XPATH only one timeFind a useful parent element and then get or assign it an IDUse this ID to reference child nodes without the XPATH crimeYour tests will be faster and more maintainable as you will see
  4. 4. Issue Threat Level Solution Velociraptor 3 Shotgun XPATH 7 CSS Delayed Flight 5 Beer [[‘Velociraptor’, ‘3’, ‘Shotgun’],[‘XPATH’,’7’,’CSS’],[‘Delayed Flight’,’5’,’Beer’]] Testing CodeOften we validate the contents of an entire table—which can be a lot!We found that grabbing the contents cell by cell is way too slowInstead use JavaScript injection to grab and return the contents in one shotReturning a JSON 2D array of the table contents is the way to go
  5. 5. Complicated Page With Dynamic Content Name: Robert’) DROP TABLE students;-- Quest: Favorite Color:JavaScript injection can helps in many other situations too!Like randomly filling in every input on the page as fast as lightningUsers love to break things so I think this is something you should doThe fact that somebody may be named Robbert’); Drop Table Students is quite frightening!
  6. 6. Complicated Page With Dynamic Content Am I visible? (Invisible Element) Of Course! Display: none? Class: hidden? LIAR! I am not a crook!Often you want to know if an element is visible, which makes senseBut visible(), like Nixon, will sometimes just lie to your faceWe use JavaScript injection to traverse the style or class attributes of parentsCombined with a regex or two, we determine visibility with grace
  7. 7. Oh no! Complicated Page With Dynamic ContentSelenium tries its best, but in some cases like a deer in headlights it may freezeTo prevent everything from hanging we run commands in a separate threadIf the join timeout is reached, we the log the error and end the test as we pleaseAllowing our teardown to properly run, instead of the whole execution being dead
  8. 8. Testing Code The test did this And then this And then this Abrah Cadabra!Log everything you can about each run in the database!Inputs, outputs, Log statements, and screenshots are what engineers craveYou can always delete information you no longer need, when that’s the caseBut only David Copperfield can produce information you did not save
  9. 9. Testing Code Click Screenshot Upload Screenshot to DB Validate Click Type ClickSpeaking of screenshots, they are an engineer’s best friend—they are divine!But sending them over the series of tubes can sometimes be quite slowWe found that having your test wait for them to upload is a sub-par designUse a separate thread to upload, and letting your test proceed, is the way to go
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×