just ram

stuff I should remember

My first wordpress post

I’ve defected from blogger.com, so far I’m impressed. Categories, stats, lots of nice skins and the import feature just saved me a boat load of time!

Functionally testing SAP Enterprise Portal using Watir

It’s taken about a day but I’ve managed to get some functional tests running using Watir. It’s not been as easy as it could have been mainly due to the way the SAP Enterprise Portal uses iFrames and the anti cross site scripting in Internet Explorer. I got there in the end though! I can now logon to the portal and functionally test iViews using a fairly simple Watir (Ruby) script:

<code>def logon
$ie.goto($html_root)

if $ie.contains_text("Log Off")
logoff()
end

$ie.text_field(:id, 'logonuidfield').set($user_id)
$ie.text_field(:id, 'logonpassfield').set($password)
$ie.button(:name, 'uidPasswordLogon').click
end</code>

A couple of things to note:

Talk to the iView directly Due to the use of iFrames and IE anti cross site scripting accessing an iView which is embedded in a portal page is not possible with the current (1.4.1) version of Watir. Simply get the url of the iView and access it directly.

Problem with HTMLB Text Fields ID’s and Names of HTMLB Text Field controls appear to be generated on execution, so I had to write a little script which would find a text field using the title property:

<code>def find_text_field_by_title(my_title)
found_text_field = nil

$ie.text_fields.each do |tf|
if tf.title == my_title then
found_text_field = tf
break
end
end

raise "No text field found with title = " +
my_title if found_text_field.nil?

return found_text_field
end</code>

NOTE: I’m sure my Ruby/Watir scripts leave a lot to be desired, I don’t really know who to code in Ruby but they do seem to work!

Searching Google for Watir help

Having trouble finding help on Watir?

Try the following in google:

site:rubyforge.org "[Wtr-general]" your search

Installing Watir via the gem utility

The install should be as simple as dropping into dos, cd to your Ruby folder and run the command: gem install watir

Unfortunately it wasn’t that simple for me, we work via a proxy here so I had to tell the gem utility about it.

Running gem install when you are behind a proxy

Set the HTTP_PROXY environment variable.

Example: set HTTP_PROXY=http://mycache:8080

You can now run: gem install watir

Or you can pass the proxy information as a parameter to gem via the -p switch:

gem install watir -p http://mycache:8080

Gem will now go off download and install the latest Watir package, version 1.4.1 in my case. Be patient this can take some time depending on server load.

Watir - Testing your website

I am hoping to use this software to test my web developments, from what I have read it looks very promising.

“WATIR stands for “Web Application Testing in Ruby”. Watir is a free, open-source functional testing tool for automating browser-based tests of web applications. It is pronounced water.”

The install…

Using the Ruby One-Click installer for windows (version ruby182-15.exe), just run standard install accepting all defaults.

NOTE: I tried the final version of Ruby 182-14 and had lots of install problems so use at least version 182-15!

Using the Watir One-Click installer for windows (version watir-1.4.1.exe), just run standard install accepting all defaults.

Now onto learning what can be done with this thing…

User Guide

Ruby Cheat Sheet

Watir Cheat Sheet

Removing PAR files from the SAP Portal

So you’ve accidentally uploaded a PAR file to the portal eh?

Here’s how to get rid…

(Top Menu) Java Development -> (Left Sub Menu) Tools -> Portal Archive Deployer&Remover

(Main Page) Archive Remover

Select the PAR file you wish to remove from the drop down list and click the “Clean” button

You should now see a message along the lines of:

INFO: Received clean-up request for application: “MyApp” INFO: MyApp has been successfully removed from the PCD.

The PAR is no more.

SAP Portal PAR locations

To find your PAR files once they are uploaded to the portal:

(Top Menu) Java Development -> (Left Sub Menu) Tools -> Portal Support Desk

(Main Page) Portal Runtime -> (Main Page) Browse Deployment

Now move to:

:ROOT/WEB-INF/deployment/pcd

You should now see a BIG list of files.

This is where your PAR files live!

Create a library project of SAP Portal PDK JARs

It is a good idea to create a library project which includes all the jar files needed for a portal project. Why? 1. The SAP consultant told us to do it this way 2. It means on each new project you just need to include the library project and we are good to go.

So this is what we need to do:

Step 1: Get the portal PDK JAR files These JAR files can de downloaded from the portal, they live under the following portal menu:

(Top Menu) Java Development -> (Left Sub Menu) Tools -> PDK Jars Download

Download the zip file and extract the JAR files to a folder on your PC for example c:\source\sap\devlibs

Step 2: Create the library project In SAP Netweaver Developer Studio create a new project:

File -> New -> Project…

You will now see a wizard dialog:

Select Java -> Java Project

Click Next

Give the project a name DevLibs for example and specify a folder to save the project to.

You should now have a blank project to work with.

Step 3: Import the SAP Portal PDK JAR files Right click your mouse on the new blank project you just created (in this case DevLibs) select Properties from the context menu.

You will now see the DevLibs properties dialog: Select Java Build Path from the left pane.

Select “Libaries” from the Tab.

Click the “Add External JARs” button.

The file open dialog will now appear, select the downloaded JAR files from Step 1.

Click the “Order and Export” tab, click the “Select all” button.

Finally click the “OK” button.

You now have a library project which can be included in new portal projects!

Add a new project to Subversion server in Windows XP

NOTE: You must have TortoiseSVN installed for these instructions to work!

First create your Project folder structure:

ProjectName
branches
tags
trunk

Place your source in the trunk folder.

In windows explorer right click on ProjectName folder and select TortiseSVN -> Import from the menu.

You will now see the import screen:

Enter the repository/ProjectName an import message and click OK.

You have now created the project in Subversion but you must still check out the source you just imported. This can be done via TortoiseSVN or directly in eclipse using the subclipse add in.