JavaScript Performance Hit Calling Function vs. Inline

I know there is a performance hit when calling a function vs just running the code right there but I was curious how much that would be in different browsers. I went over to one of my favorite JS testing sites, , and setup a simple test. Running a few tests on a few different browsers suggests that there is about a 50% performance hit when calling a function with a small task.

You can check out the most recent results at and test your own browser.

Taking Screenshots In Selenium Using Ruby

I LOVE being able to take screenshots of my Selenium tests as they are running!

Here’s how I take screenshots of my selenium tests running, written in Ruby:

  • Find the variable referencing the selenium driver. Might look something like this:
    @selenium_driver =
  • Wait for condition to take screenshot. Example:
    page.wait_for_element("//h1", {:timeout_in_seconds => 10})
  • Take screenshot. Example:
    @selenium_driver.capture_entire_page_screenshot(File.expand_path(File.dirname(__FILE__)) + 'screenshot1.png', '')

    or something simpler like:

    @selenium_driver.capture_entire_page_screenshot('~/Desktop/screenshot1.png', '')

Selenium documentation for using the capture screenshot function.

Escaping Ruby Strings For Eval In Selenium Tests

If you are setting up a string in Ruby to then be used in an eval statement in a Selenium test you’ll need some escaping fu to be able to pull it off.

Quotes in strings that are then going to be put in other Ruby strings need to be tripple escaped. If the string is going directly to the eval in Selenium then only a single escape is needed.

first = "first quote: \\\"......"
second = "#{first} second quote: \\\".........."
jsfunction = "window.alert(\"#{second}\")"
puts jsfunction

it "should alert string" do

selenuim ruby string escaping for eval

Access Local Mac Dev Environment from VM

Testing my web development in IE is the bane of my existence. Since I run Apache and MYSQL on my local host on my Mac it was always a trick to view my work though my Windows VM until my friend Mike Farmer showed me an easy way to access my development environment on my Mac from my virtual machine.


  1. Get default gateway of VM machine
  2. Use that address the same way you would “localhost” on your Mac


Get IP address of VM
Get IP address of VM
Local Mac development environment
Local Mac development environment
Dev environment from VM
Dev environment from VM