Showing posts with label windows 7. Show all posts
Showing posts with label windows 7. Show all posts

Friday, August 6, 2010

Accessing Network resources as Administrator on Windows 7

One of the problems I had when using RubyGems (Ruby 1.91) on Windows 7 was that my homedrive is on a network drive.
So when running rubygems in an elevated command prompt (ie running "As Administrator"), rubygems exited with an error something like could not access H:\. Now this is a problem for me since I want those rubygems on my laptop because I want to be able to work offline (ie at home etc).

After some googling I found out that when running as Administrator the network resources that you have as a normal user are not accessible when you are running as Administrator.
This article here from Microsoft support describes how to do this. Cutting to the chase, you need to:

  1.  create an DWORD key in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System called EnableLinkedConnections and set it's value to 1. 
  2. Reboot
And that's it! Now your existing resources are available when you run as Administrator.

Friday, July 23, 2010

Getting started with Selenium 2.0 and Ruby

Since my previous post about this was a bit trollish, I decided to redo it.
selenium-webdriver with ruby 1.86+ should work out of the box. But with ruby 1.9x and windows you might need too do some tiny troll magic.

Resources:
Ruby installers
Selenium-Webdriver Ruby Bindings
How to fix the msvcrt-ruby18.dll Ruby 1.9 problem

Installing Ruby
If you haven't installed ruby yet, you will need to do so. Head over to http://rubyinstaller.org/downloads/ and grab the one you prefer (I used ruby 1.91). Install it.

Installing the selenium-webdriver gem
After that we need to install the selenium-webdriver gem. Fire up a cmd/terminal. Some systems might force you to do this as an administrator, see Howto start cmd as an Administrator.
On OSX make sure to use sudo, note that you need administration privileges to be able to use sudo.

Windows: gem install selenium-webdriver
OSX and other sudo thingamajig: sudo gem install selenium-webdriver


Try the example:
Now if you want you can try the example at the RubyBindings page.
If this works now, you don't need to do anything more! If you get a popup about msvcrt-ruby18.dll then you need to read on.


Fixing the "msvcrt-ruby18.dll missing" problem:
Windows and Ruby 1.9 only
The problem is in the win32-api dependency, (one of the gems installed). The solution is outlined here.
What you need to do is to rebuild that gem locally, to do that you need to install the devkit from rubyinstaller.org.

Download the devkit at the Rubyinstaller.org download page.
Unpack it into you ruby installation root directory (for me it was C:\Ruby191)

Run the commands detailed in the fix post.
gem uninstall win32-api 
and  then
gem install win32-api --platform=ruby

This should be it, your example should run fine now.

Next post:
Next post will be about "rubyfying" example 2 in the 5 minute getting started guide for Selenium 2.0

Thursday, July 22, 2010

The troll takes on selenium 2.0

EDIT: On checking the selenium-webdriver gem, it seems to include everything needed to drive the browsers. So step 2-4 is not really needed. But still, below is exactly how I did this yesterday.

Not that I really work with testing anymore, it still interest me. Well at least getting it more and more automated.
So getting Selenium 2.0 running on my windows laptop sounded like a good summer activity.

In fairness the people responsible for both Selenium 2.0 and selenium-webdriver (which is the ruby frontend, packaged as a ruby gem) did a fantastic job.

You need following installed to get it working:
Firefox (or else you can change the example code to use IE or Chrome etc.)
Ruby 1.9
(Selenium 2.0)
And a few more stuff detailed below.
  1. I installed first ruby 1.8.7 and the ruby 1.9.1 from the one-click installers.
  2. Then I went to the SeleniumHQ and specifically they're Webdriver page.
  3. Downloaded the complete package (selenium-server-2.0a5.zip) from the downloads page.
  4. Unpacked it and added that directory to the CLASSPATH environment variable (I used C:\selenium-2.0a5).
  5. Fired up a cmd prompt and installed the selenium-webdriver gem (gem install selenium-webdriver).
  6. Navigated to the ruby bindings webpage for the WebDriver API => http://code.google.com/p/selenium/wiki/RubyBindings
  7. Fired up gvim (feel free to use your favorite editor here!)
  8. Copy and pasted they're first example and it failed horrible. (Note that on some systems you will need 'require "rubygems"', best is to always use it). Save as google_test.rb
  9. Googled the problem "msvcrt-ruby18.dll selenium-webdriver", found a related watir problem => http://code.google.com/p/selenium/issues/detail?id=583
  10. Installed the devkit from rubyinstaller.org, devkit is available for download on this page => http://rubyinstaller.org/downloads/
  11. unpacked the contents into my ruby 1.9 directory (I use C:\Ruby191)
  12. fired up the cmd again and ran
    gem uninstall win32-api
    gem install win32-api --platform=ruby
    as detailed in the watir fix
  13. Then "ruby google_test.rb" in the cmd and everything worked as intended!