Automated Testing Tricks is a series of posts that discusses fun things you can do with your automated testing tool that may not be directly considered automated testing.
“Hey, Hey Hey, Hey!” Would you like to go to a live taping of the Tonight Show with Jimmy Fallon? I sure did, and when my wife and I were given the opportunity to spend a long weekend in the Big Apple, we pounced on the chance to get tickets for the the show.
After doing some digging, I learned that tickets are free (Woo-Hoo!!) and distributed on a first-come, first-served basis online (Uh-oh.).
Like most people, I work long hours, coach youth sports, spend time with my family, etc. I’d have a better chance at bumping into Jimmy in a spinning class than getting tickets in a “first-come, first-served” contest.
So that got me thinking: is there some way that I could be alerted as soon as the tickets become available so that I can be one of the “first” without aimlessly clicking the Refresh button on their website over and over again?
Thankfully the answer is “Yes!”
How to get tickets
First things first. How do you get tickets for the Tonight Show online?
The Tonight Show has a reservation page where they list the dates that they’ll be filming over the next few months.
If you click on any of the dates you’ll quickly realize that they’re all sold out. This is ultimately the result of not beating everyone to the front of the line for the “first-come, first-served” tickets.
But the good news for you is that they only release the filming dates a month or two in advance. Therefore, if you plan accordingly, you have a fair chance at getting tickets for dates that aren’t listed yet.
Use your Automated Testing Tool to alert you
There are a number of automated testing tools that you can use to test websites. My personal tool of choice is Tellurium, but you could use other tools like Selenium, HP, etc. The important thing is you’ll need to be able to schedule your test to run frequently and receive alerts when your test fails.
The first thing we need to determine is: what is it that we’re testing?
Since we’re looking for a particular date (ideally one that isn’t listed on the reservation site yet), we’ll want to create a test that checks to see whether that date appears on the page.
Creating your test
There are a few pieces to this test and we’ll walk through each one of them.
The first thing your test needs to do is navigate to the reservation page and check to see if your desired month is listed. This will most likely mean clicking the “Next” arrow to check for a future month.
Once your test finds the month that it’s looking for, you’ll want it to check for the specific date on the calendar. Thankfully the dates are links, so locating them via an automated test isn’t difficult.
If your test can click on your date, and the reservation drop-down menu appears, then your test should FAIL.
Why fail? Some testing tools will notify you whenever your test fails. In this case we WANT to be notified as soon as that drop-down menu is available. Therefore we need to trick our test into thinking that it’s failed so that it’ll notify us.
Personally, I was hoping to get tickets for June 27th. Using Tellurium, I created the following test:
For the url http://www.showclix.com/event/thetonightshowstarringjimmyfallon
If the text “May” is present
If the “Next” link is present
When the “Next” link is clicked
Once the text “June” is present
When the “27” link is clicked
If the “event_time” drop-down menu is present
Then fail this step
Then pass this step
Feel free to copy/paste that test into Tellurium and try it yourself. Simply replace “May” with the current month, “June” with your target month, and “27” with your target date.
Schedule your test to run automatically and notify you if it fails
Once you’ve created your test you need to schedule it to run automatically. Tellurium has a built in scheduler, but you could always create a cron job or use some other scheduling mechanism if you’re using another tool.
Ideally you want your test to run as frequently as possible so that you’re notified as soon as you can reserve tickets on the site. I set my frequency to every 5 minutes, but you could theoretically set it to run every minute.
Once you’ve scheduled your test, make sure that your testing tool notifies you if your test fails. Most tools have a mechanism to email you if and when critical tests fail.
And that’s it! If you set everything up correctly your test will automatically run every few minutes, checking the site to see if you can reserve tickets for your desired date.
Now you can sit back and wait for the email to arrive so that you can get your tickets before anyone else.
Have you used your automated testing tool to reserve tickets online? If so, share the details in the comments below.