Watir on Shoes

Yesterday evening I tried to create a prototype using Ruby which should have a simple GUI to insert test data for Watir testscripts.

Shoes is a Ruby library/framework for drawing 2D and web-like UIs which can be compiled into native executables (e.g. *.exe on Windows, *.dmg on MacOS X). Watir is another Ruby library which can be used for automated browser testing. I just thought it would be a good idea to combine this two Ruby libraries to create powerful test environments.

I tried to load the Watir lib in Shoes. Shoes knows the setup block to load libraries via “gem”:

Shoes.setup do
  gem 'name >= version'
end

I added further code and tried to run it via Shoes. Then Shoes automatically opens a window which told me that it tries to install Watir. But after a short time I’ve got an error:

hoe requires RubyGems version >= 1.3.1

“Oh no, the wrong RubyGems version…”. So I thougt updating RubyGems would solve the problem.

Console: gems --version
> 1.3.1

Console: gems update --system
> updating... [take a coffee break]

Console: shoes watir_on_shoes.rb
> hoe requires RubyGems version >= 1.3.1

“Arg, still the same error…”. Time to ask my friend Google, but Google just knew the problem, not the solution. Suddenly I remembered the fact that Shoes contains its own Ruby environment… and you might guess that – also a RubyGems distribution. So I found an easy working solution:

Copy all files from

%RUBY_HOME%\lib\ruby\gems\1.8\gems\rubygems-update-1.3.4\lib\rubygems
to

%SHOES_HOME%\0.r1134\ruby\lib\rubygems

That fixed the problem and Watir was properly installed. Maybe you are interested in my simple prototype:


Shoes.setup do
  gem 'watir >= 1.5.6' # might be out of date
end

require 'watir'

class ShoesWatirTest < Shoes

  url '/', :index

  def index
    stack :margin => 20 do
      title "Watir-test"
      flow do
        para "URL:"
        @search = edit_line
        button "GO!" do
          @ie = Watir::IE.new
          @ie.goto "http://www.google.de/"
          @ie.text_field(:name, "q").set @search.text
          @ie.button(:name, "btnG").click
          para @ie.text
        end
      end
    end
  end
end

Shoes.app :width => 400, :height => 800

Posted in Ruby | Tagged , , | Leave a comment

Ruby on Windows: OLE automation for Outlook – Shared calendars

Ruby has a nice library for OLE automation, win32ole. I used this library to get appointments from shared outlook (exchange) calendars. The scripts are testen on Windows Vista with Outlook 2003. This is how it works:

outlook_reader.rb

require 'win32ole'
outlook = WIN32OLE.new('Outlook.Application')
mapi = outlook.GetNameSpace('MAPI')

# this is explained later
Thread.new do
  system('outlook_clicker.exe')
end

# create a recipient and resolve him
myRecipient = mapi.CreateRecipient("John Doe")
myRecipient.Resolve

# get the shared calendar of the recipient
if myRecipient.Resolved
  calendar = mapi.GetSharedDefaultFolder(myRecipient, 9)
end

# write the calendar data to the output
if calendar
  calendar.Items.each do |item|
    puts "#{item.Start} - #{item.End}: #{item.Subject}"
  end
end

Outlook has a mechanism which should protect the outlook data from unauthorized access, e.g. viruses and trojans. Everytime you want to access the data from outlook a popup opens which asks you, if the access should be granted. In case of automation this is very bad, because you usually don’t want to click anything if you automate a process.

So here the solution. I’ve created a ruby script which clicks the dialog for the user. Then I converted it into an executeable using RubyScript2exe (Ruby code gets compiled).

outlook_clicker.rb

require 'win32ole'

# new shell object
wsh = WIN32OLE.new('Wscript.Shell')

# for timeout management
time_out = 0
time_out_max = 10
interval = 0.01

# try to activate the window with the Title 'Microsoft Office Outlook'
while !wsh.AppActivate('Microsoft Office Outlook') do
  time_out = time_out + interval
  sleep(interval)
  if time_out > time_out_max
    Process.exit!
  end
end

# if the popup exists and the timeout is not reached some
# keys get send to the popup
wsh.SendKeys("{TAB}")
wsh.SendKeys("{TAB}")
wsh.SendKeys(" ") # this is "space"
wsh.SendKeys("{TAB}")
wsh.SendKeys("{TAB}")
wsh.SendKeys("{ENTER}")

To compile this ruby file into an executeable rubyscript2exe can be used. To install it you can use Ruby Gems (command prompt):

gem install rubyscript2exe

After installing you can open a command prompt, change to the directory your scripts are in and compile the clicker using the following command

ruby rubyscript2exe.rb outlook_clicker.rb

The executable will be created in the same directory. In the file outlook_reader.rb the following lines call the outlook_clicker.exe:

Thread.new do
  system('outlook_clicker.exe')
end

In this three lines a new thread is created which calls the outlook_clicker.exe using the system method. Basically we reached that both scripts are executed in parallel.

If you execute the outlook_reader.rb you can see that the popup shortly opens and then automatically gets closed.

Recommend reading: http://rubyonwindows.blogspot.com/

Posted in Ruby | Tagged , , , , , | Leave a comment

Ruby & SAP Services (SOA)

I recently added two links to my blog. They both lead to articles I wrote about Ruby (on Rails) and SAP Services. Warning: This was before Rails 2.0 was released. Ruby on Rails make cool SAP MashUps possible.

How-to: Consume Enterprise Services with Ruby on Rails – Part I

How-to: Consume Enterprise Services with Ruby on Rails – Part II

Posted in Ruby | Tagged , , , , | Leave a comment

iBox3D – Calendar week 19

No news about iBox3D for the last two weeks? You might ask yourself what happened. The answer is simple: Not much time to write about my ongoing work on iBox3D. But now it’s time to report about the current process stage.

iBox3D is currently in a phase where all the features are implemented rudimentarily. You are able to play, to resume a game, to view the offline and online high score. That means that the game mechanics are all working, but sadly they are mostly not 100% implemented.

I put the requirement to myself to push the 90%-ready features as far to 100% as possible in the next weeks. To fulfil my personal quality goals I will put much effort in the polishing of all the features.

But now I’d like to inform a little bit about the online high score I was working on for the last two weeks. From a technical point of view the high score uses XML via HTTP for the communication between the client (iBox3D on an iPhone/iPod touch) and the server. The client holds the player’s local high score whereas the server holds the high score of the players all around the world and is able to generate rankings.

From a conceptual point of view a player is not forced to use the online high score. But if the player enters the online high score from menu all things needed for the participation in the online high score are automatically prepared. The user gets an unique account for his typed in name (which is by the way changeable without loosing the current high scores), his scores are sent to the server and a list of the top ten players and the current placement of the player is requested. If the iPhone/iPod touch is connected to the internet and the data is successfully transmitted then the top ten and the player ranking are per level displayed on the screen.

In reality the high score is a low score. As the main idea is to have as little moves and as little time as possible per level it makes more sense this way. Currently the number of moves and the time are taken into account equally. They are simply multiplied. E.g. if you needed 10 moves to complete the level and it took you 21,3 seconds, then your personal score is 213. If someone would only need 9 moves and 19 seconds then the score would be 171. That means that this player would be better. Expect slight changes to the high score during the beta phase.

After the content lots of content, e.g. levels and music, has to be created. This steps will make the game ready for the beta test.

Posted in iBox3D | Tagged , , , , , , | Leave a comment

iBox3D – Calendar week 17

The status of iBox3D has not changed much last week. In fact I only added an online highscore prototype. The server side is yet working and the client side (iBox3D) is able to display the best scores per level and your personal rank. The prototype should be finished up this week so that I can start polishing the game next week.

Posted in iBox3D | Tagged , , , , , , , | Leave a comment

iBox3D – Calendar week 16

iBox3D development goes on and on. I’ve added a menu, a highscore, sounds and music. Still in alpha version I’d like to present some screenshots and a gameplay video with sounds and music. Feedback is welcome.

If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

iBox3D - Moving BoxiBox3D - Box on the flooriBox3D - HighScore

Posted in iBox3D | Tagged , , , , , | Leave a comment

iBox3D – Calendar week 15

Due to some requests from internationals I’ll start to write blog posts about iBox3D in English.

Today is the last day this week I’m working on iBox3D (iPhone game). This week I added some new features to the game.

Switches
The switches can only be activated if the box is standing upright on them. Currently one switch is directly linked with one floor platform which appears after the switch is activated and fades again if the switch is re-activated (toggle mechanism). Switches may offer new ways for the box.

Unstable platforms
This kind of platform is not as stable as the standard platforms. When the box stands upright on an unstable platform, it will fall down and the level is lost. If the box lies on one stable and one unstable platform nothing happens. But if the box lies on two unstable platforms it again falls down into the infinite darkness. So you always have to keep the balance.

I also added another FX effect. When the box hits the floor some dust particles show up.

Gameplay videos will follow as soon as I create levels using the new features.

Again I’d like to remark, that you can play a demo with four levels here using the browser plugin provided on the page or on StoneTrip.com. Feel free go give me some feedback.

Posted in iBox3D | Tagged , , , | Leave a comment

iBox3D

Ich schreibe heute über mein erstes Spiel, das voraussichtlich irgendwann dieses Jahr für das IPhone erscheinen wird.

Der Working-Title des Spiels ist iBox3D. Ich glaube, dass ein “i” als Anfangsbuchstabe fast Pflicht für coole IPhone Games ist.

Nun zum Spiel. Es ist angelehnt an ein Flash Spiel, das ich während meines Studiums der Wirtschaftsinformatik nur zu gerne gespielt habe. Zu finden ist die Vorlage hier: Bloxorz.

Dabei geht es um einen Block oder eben eine Box, die eine Einheit lang/tief und zwei Einheiten hoch ist. Diese Box steuert man durch geschicktes Umwerfen und Rollen über mehr oder weniger zusammenhängende Plattformen in das Ziel. Wer von den Plattformen fällt gewinnt.

Meine erste Version habe ich mit Shiva erstellt. Damit man sie auch ohne IPhone testen kann, habe ich eine Web-Version mit den ersten 4 Levels veröffentlicht. Ihr findet das Spiel hier. Um es spielen zu können benötigt ihr noch das Shiva Browser Plugin, das ihr auf der Seite des Spiels herunterladen könnt. Falls ihr der Sache nicht ganz traut findet ihr hier mehr Informationen zum Plugin.

Ich möchte anmerken, dass das Spiel noch im Alpha Status ist. Wenn ihr coole Ideen habt, dann schreibt mir doch einfach.

Features to come:

  • Spielmenü
  • In-Game Oberfläche
  • Fortsetzen des Spielverlaufs (Speichern)
  • High-Score
  • zwischen 20 und 30 Levels
  • Schalter, die versteckte Plattformen erscheinen lassen
  • Plattformen, die bei falscher Belastung abbrechen
  • Bewegliche Hindernisse
  • Sound & Musik

Happy Testing.

Posted in iBox3D, Stonetrip's Shiva | Tagged , , , , , | Leave a comment

Shiva – Ein einfacher Weg zum 3D Spiel

Ihr wolltet schon immer ein Spiel entwickeln? Ihr seid aber nicht firm mit C/C++? Ihr wollt einen Welteditor wie bei Unreal / Warcraft III? Dann solltet ihr euch Shiva anschauen.

Ich kann zwar mit C++ coden, aber dennoch muss man erst vieles selbst programmieren, wenn man ein eigenes 3D Spiel erstellen möchte. Wenn man eine 3D Open Source Engine Spiele-/Rendering Engine wie Ogre3D oder Irrlicht benutzt, kann man recht schnell 3D Szenen erstellen. Vieles muss man sich allerdings manuell zusammensuchen. Einen Welteditor gibt es beispielsweise auch für Irrlicht. Bis man diesen allerdings wieder in die eigenen Games integriert und auf die eigenen Bedürfnisse angepasst hat, vergeht eine Ewigkeit, in der man nicht direkt sein Spiel erschafft, sondern nur die Entwicklungswerkzeuge.

Wer diesen Schritt überspringen will, für den sind Entwicklungsumgebungen wie Unity und Shiva die bessere Wahl. Mit einer grafischen und voll integrierten Spieleentwicklungsumgebung kann man recht einfach alle Objekte in klassischer WYSIWYG-Manier positionieren und ihnen mittels Scripting Leben einhauchen. Shiva hat dabei den Charme, dass eine Personal Learning Edition frei zur Verfügung steht. Darüber hinaus ist auch eine Shiva Lizenz, mit der man Spiele auch kommerziell vertreiben kann, für einen Preis von 169 € recht günstig. Dazu noch ein Geheimtipp von mir: Stonetrip reduziert die Preise ab und an zu gewissen Anlässen. Ich konnte meine Shiva Unlimited Lizenz für 89 € im Wintersale erwerben. Ich persönlich glaube, dass Unity vom Bedienkomfort und vom Workflow her betrachtet auch ein wenig intuitiver ist. Allerdings ist hier die Lizenz wesentlich teurer (448 € für die Basisversion mit IPhone Publishing) und eine Demo ist nur für 30 Tage verfügbar.

Warum gerade Shiva und Unity? Das Stichwort ist IPhone-Publishing. Beide Entwicklungsstudios ermöglichen das Veröffentlichen von Spielen auf verschiedenen Plattformen, beispielsweise Windows, MacOS oder eben auch auf der Nintendo Wii und dem IPhone. Da das IPhone mit einem besonders einfachen Vertriebskanal aufwartet und die Spiele nicht ganz so komplex wie PC Spiele sein müssen, ist das IPhone besonders für 1-Mann Spieleentwickler interessant.

Ich für meinen Teil werde Shiva genauer beleuchten. Wer aber generell einen Überblick über Game Engines sucht, der findet diesen auf DevMaster.net.

Posted in Stonetrip's Shiva | Tagged , , , , , , , | Leave a comment