Tuesday, July 12, 2011

Firewatir vs Webdriver

I've moved from Firewatir to Webdriver recently and have noticed a few changes.  Specifically a change that halted one of my scripts and took a little prodding for a workaround when it was simply clicking links.

I have a Ruby script that opens a website, reads data, and if it's not a file I currently own it downloads it.  Two links, one opens a span and another is the download link - both have onclick javascript events.

In Firewatir to open the span or download the file, just click.

browser.link(:xpath =>"//someDiv[@id='siteLink']/xpath/to/link/a").click


This worked no problem until I tried Webdriver.  Now the page would only center on the span containing the link, but it would not open or start the download.

Doing some Google searching, I came across a Stackoverflow answer from the awesome Watir guru Ċ½eljko Filipin.  Seriously, Zeljko, you rock.  For Webdriver the correct way to get these links to register is to directly fire the javascript event.

In Webdriver,

browser.link(:xpath =>"//someDiv[@id='siteLink']/xpath/to/link/a").fire_event "onclick"


Why there is a difference I'm not sure.  But this change allowed my script to use Webdriver and get back up and running.  It was a bit frustrating since everything had worked right for so long, and testing regular links worked just fine but I'm just glad to be able to use Webdriver with Firefox and get moving again.

Monday, June 20, 2011

VirtualBox Linux Kernel Driver Problems

Recently wiped all windows installs at work so I'm using OS X on a MacMini, and Fedora 15 on a dell workstation.  I still have a number of windows images I need to connect to so that means I need some kind of Virtual Machine setup for windows programs.  Cue the free VirtualBox program.  (Free is always a good price!)  I could setup Wine, but I have some specific uses for XP images so that's why I'm sticking the VM route.

Anyway, the first time I attempted to start up the VirtualBox instance, I received an error, "Kernel Driver not installed".  On a newly installed Linux image, this isn't a problem and you can follow the steps listed.  I  had one special case for my box though...

Solution:
Anything following a hashtag, #, is just a comment and can be ignored.  It's simply there as a note.
1. As root, login and install the DKMS (Dynamic Kernel Module).

su -
yum -y install dkms



# -y defaults to yes, or don't prompt me, just install it

This simple goes out into the Fedora repositories and proceeds to pull down and install the "dkms" module.  Simply, this will allow VirtualBox to reconfigure and install itself as a module into the kernel, even when the kernel version changes.  Very handy instead of having to redo by hand anytime you update the kernel. 

2. As root, rerun the VirtualBox setup.

/etc/init.d/vboxdrv setup


Here VirtualBox will attempt to stop the kernel modules, uninstall any previous versions, reregister using DKMS (from step 1), then start the modules.

Here is where you can get some errors.  You will need to first install the kernel headers and development files for your Linux kernel.  Anytime you want to work with your kernel, you're going to need these files, so it's a good idea to get them on your system.  Here is where I found my specific error - my kernel version, and the header/development files were not the same version!  You are going to want to update your system first, so you get the latest  kernel version, that way everything matches.  This can be difficult to tell sometimes since kernel versions can be long and hard to read sometimes.

So, if you still got errors from Solution:2,

3. As root, update the system then install the header and development files.

su -
yum -y update  # update everything, including the kernel
yum -y install gcc make kernel-headers kernel-devel  # gcc and make are needed to link program files


4. Reboot and rerun step Solution:2

shutdown -r now
# Wait for reboot to finish, then log back in as root user
su -
/etc/init.d/vboxdrv setup


Finally, I now have a workable VM that does not complain.

What did we learn?
When working with kernel modules, you must have two things,
1. Installed headers and development packages
2. Matching version number for kernel and it's headers/development files.

Now, back to work!