Leo

I’ve had multiple situations where I’ve wanted to watch my automated test run on video. Screenshots are great, but sometimes they just don’t catch the full gist of it. Thanks to Jari Bakken for the vnctools gem.

Items you’ll need to install:
gem: vnctools
apt-get install ffmpeg
apt-get install jenkins-ci

Jenkins plugins required:
XVNC plugin must be configured

Sample code:

require 'vnctools'

def start_new_video
@video_name = 'text_run_video.mp4'
@recorder = VncTools::Recorder.new(ENV['DISPLAY'], @video_name)
@recorder.start
end
def stop_video
if @failure_count > 0
@recorder.stop
puts "Video recorded at #{@video_name }")
else
@recorder.stop
end
end
end

Bugs provide unique tools for communication of problems between QA and engineers. Too often, QA engineers enter environments where bugs are written like this:

Title: Something broke
Description: I did some stuff, it broke, I don’t quite know what, or how it broke, but I swear it broke. Developers fix this, it’s super important!

Obviously the above bug report is awful. Zero information is provided to developers or other app-owners. Over time I’ve found a good format for writing good quality, reproducible bugs. This format is system independent, so can be used in nearly any Bug Tracking system(Mozilla, JIRA, Trac, Test director, etc etc). It does take into assumption that some fields are available on the bug tracking system. If they aren’t, just put “Field name: ” in the description field of the bug.

Title: This is a general description of the bug in 1 sentence or less
Priority: The bug priority, usually ranked 1->5 or trivial->blocker. Different organizations have different descriptions of each priority type but I like to stick with the following for myself:

(1)Blocker: Testing can not continue, the system is down, some unrecoverable state. There is no work around.
(2)Critical: Testing can not continue down this path, but there may be a work around.
(3)Major: Testing can continue, but this is a client visible issue that will bite us sometime in the future. It might impact a large client
(4)Minor: Testing can continue, no large client impact.
(5)Trivial: Spelling mistakes, grammar, image problems, etcetera

Steps to Reproduce: This is a numerical list of the exact steps you took to reproduce the bug. If the bug is not reproducible following these steps, the bug should not be filed. I can’t stress the importance of filing reproducible bugs. For example to “Save As” a document in Microsoft Word 2010 the steps are
1) Click File
2) Click Save As
3) Enter a file name in the file name field
4) Click save

Actual Results: This is where you write down what actually happened. For the above steps the actual results are:
The file was saved

Expected Results: This is where you write down what you expected to happen. The above steps had the expected result:
File should be saved

The above fields are a bare minimum for filing any bug on any system. Things like screenshots, attachments, firebug results, stack traces, etc are always useful but if the bug is truly reproducible with the steps provided above, are extraneous information.

When running firebug in firefox via the Selenium webdriver, consider that everytime you run your test, firebug acts like its the first time it’s ever been run(since this is a new browser profile).

I was recently shown a way to disable the first-run tab from appearing.

The Ruby code is below. It also shows how to add firebug and firepath to it as well as setting some custom profile/client rules for firefox


profile = Selenium::WebDriver::Firefox::Profile.new
profile["dom.max_script_run_time"] = 500
profile.log_file = ("C:\\Selenium\\firefox.#{Time.now.strftime("%Y-%m-%d.%H%M%S")}.log")
profile.add_extension("C:\\Selenium\\firebug-1.8.2.xpi")
profile["extensions.firebug.currentVersion"] = "9.99"
profile.add_extension("C:\\Selenium\\firepath.xpi")
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120 # seconds

driver = Selenium::WebDriver.for :firefox, :profile => profile, :http_client=> client

Using CSS selectors in Selenium

So we all know how CSS selectors work but using them to identify elements on a page can be difficult in Selenium, and especially confusing for the beginner Selenium user.

Lets suppose you have a web element that looks like this

<a target=”foo” href=”bar.htm”>SomeWebLink</a>

How would you reference this element?  Well if its the only <a> element on the page, you can definitely call it using by tag.  However, typically it isn’t the only link on the page.

Here are a few ways to call the element by CSS selector:
a
a[href='bar.htm']

Now lets try a harder example:

<a target=”foo” href=”bar_somerandomnumber.htm”>SomeWebLink</a>

Given that the href is constantly changing(lets assume that the random number changes on every page load), you can’t quite specify the href.  However, we can use the beginning and end if we know it.
a[href^=bar][href$=htm]

The ^ tells it to search from the beginning of the attribute and the $ says to search from the end.

To simulate a grid with multiple machines on your local box, you can actually just open multiple command prompts and run seperate instances of the selenium jar in each.

To do this you need to have 1 command prompt running as the hub:


~$ java -jar selenium-server-standalone-2.5.0.jar -role hub

The other command prompts can be added with a specific type of grid instance running in each


~1$ java -jar selenium-server-standalone-2.5.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5559 -browser browserName=firefox

~2$ java -jar selenium-server-standalone-2.5.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556 -browser browserName="internet explorer",platform=WINDOWS

Note the special browsername specification for IE. This comes from the bottom section of the grid specification where they specify special browserNames for different types of browsers

Unfortunately, I was unable to find this specified in any documentation, so I’m putting it here in hopes people will have the same questions I do.

If for some reason you need to run your webdriver tests in DEBUG mode, and don’t want to use the -r flag next to your ruby call (ruby -r testfile.rb….) you can just put $DEBUG=true at the top of your testfile.rb which will also put webdriver into debug mode.

I recently decided that instead of having a standalone Jenkins task to run a Selenium RC server, I’d have it run only on demand of a script, which means, that I have to create a rake file. Unfortunately the documentation at http://selenium.rubyforge.org/document.html was heavily outdated and in need of updating.

Thankfully after some research and discussion I came to the following solution:

Rakefile:

require 'selenium/rake/server_task'

Selenium::Rake::ServerTask.new do |t|
t.jar = "/mnt/jobs/rake/selenium-server-standalone-2.2.0.jar"
t.port = 4444
t.opts = %w[-some selenium options can go here]
end

Then in my main ruby script which controls most of the jobs inside my automation I added the following:


#at top of code
system('rake -f \'rakefile.rb\' selenium:server:start')
sleep 5

#at bottom of code
system('rake -f \'rakefile.rb\' selenium:server:stop')

I also added an appropriate sleep after the server start, to let it come online. I did 5 seconds, I am sure I could cut that down, but why? One thing to be wary of is the use of the system() function, you might want to consider using IO.popen instead.

Big thanks to jarib and adamgoucher for their suggestions/help

Dear Restuarenteur,
Let me beging by saying, that I don’t pretend, nor plan to ever own a restaurant. I don’t know a lot of the inner workings, or financial backings of running/owning a restaurant. However, I do love food, and restaurants, so I have been to quite a few in my life.

I want to talk to you about the Groupon phenomenon, especially as it applies to new up and coming businesses, and especially in the food industry. Recently a new restaurant opened in my town. They took over the location of a former well established business and while keeping most of the tradition, added a little different of a flair. Think diner food. Antique car shows on Saturdays. Small town, greasy spoon. Awesome.

Within a month of opening, having visited the establishment a couple of times, I was the first to reccommend on Facebook that they look into doing a Groupon when they asked what might help grow their fan base, because hey, who doesn’t like cheaper food for the same quality. I want to apologize, because this was a mistake.

The greasy spoon ran 2 groupons. Both were run on this past Friday. One was for 7$ for 15$ worth of breakfast, the other 10$ for 20$ worth of lunch/dinner. My wife and I bought a combined 3 groupons, because we knew we’d be visiting this place often. It’s right down the street, and as I said before, the food is ok. Well worth the 7$. This morning(Sunday) we decided to visit and get some breakfast. What started out as a nice trip for breakfast turned into an ordeal.

Upon arrival we both immediately remarked upon how busy the place looked, just based on the parking situation. The lot was full, and the place was definitely humming. Groupon definitely did a GREAT job of promoting this restaurant. However, the restaurant wasn’t ready! The staff was not fully trained(remember it’s been roughly a month!), nor were they ready for such a rush. We walked in, and it took us nearly 30 minutes to get coffee. Our neighbors who got there 20+ minutes before us had not gotten their food nearly an hour after sitting down. In fact, we got our breakfast delivered before them. Waitresses were disorganized and seemed to take forever to get to customers, for coffee, placemats, silverware. I wasn’t the only one to voice a (private, between my wife and I) complaint. I know others were more vocal with the restaurant employees about their dissatisfaction.

So what is my suggestion to you, oh restauranteur, then and now? Wait. I know that instant payday that Groupon(or its relatives, buywithme, livingsocial, coupme, bloomspot and the like) can provide is wonderful. I know that it instantly promotes your restaurant and gets a lot of people at the door. But wait.

Ask yourself, are you ready for the influx? Are you ready for 1000 new customers, roughly 25% of which will probably try your restaurant in the first weekend? What will they say to their friends? Will they tell them that they had an awesome time, the food was as expected, and they definitely feel like they got their money’s worth? Did they spend more then the basic 15$ at your restaurant? Will they come back? Will they tell/bring friends? Or will they, as many customers I saw today, leave with a bad feeling in their stomachs? Will customers who have visited your establishment prior to Groupon be upset by the lack of service? Don’t forget the rule that 1 word of negative publicity is equal to 1000 words of positive publicity. Especially in the restaurant industry.

So to my local restauranteur, I hope this can be a learning experience. I hope that you stick around. Despite the hiccup today, I/we will be back for more breakfasty greasy goodness. We’ll still tell our neighbors that we like you. We’ll bring friends. Just before you run your next big promo, be a bit better prepared.

I needed to identify what system I was on today for my automation. I found a quick and simple way to just pull the platform out of an environment variable.

def GetOS()
if RUBY_PLATFORM.include? "mingw32"
return "Windows"
elsif RUBY_PLATFORM.include? "linux"
return "Linux"
elsif RUBY_PLATFORM.include? "darwin"
return "Mac"
end

This function returns a string which contains the platform type.

We did have an exciting trip to Petsmart with Gunner on Wednesday night. Janet from BBR had warned me that he was an escape artist/runner. I opened the car door to leash him so we could get into Petsmart to get him a collar and a dog tag with his name/identifying info. As I was about to attach the leash, away he goes. We chased him for 45 minutes, and I thought he was gone forever. We couldn’t find him. I drove home very dejected/upset, and determined to call the local police as well as post on the local email mailing list. At the last minute, after I had pulled into the driveway, I decided to call Petsmart.

Petsmart: Hi, Petsmart, how can I help you
Me: Hi, what do you do if someone brings in a dog they found?
Petsmart: Well I don’t know. We just had someone do that.
Me: You mean, like, just now? What color?
Petsmart: Black and white
Me: Are they still there? Please tell them to wait. It’s my dog. We were trying to come to your store, and he ran away from us!
Petsmart: We close in 10 minutes
Me: I’ll be there in 5.

We got to Petsmart, and the guy who had found him was happy to see us. Unfortunately he left before we were able to give him a reward of some sort. I was thinking a 50$ petsmart Gift Card.

From now on Gunner will be leashed for sure before he gets out of the car. I’m also thinking of purchasing him an electric fence to teach him not to run.

© 2012 Randoms from Blackberry Suffusion theme by Sayontan Sinha