My blog has moved!
You should be automatically redirected in 5 seconds. If not, visit http://samueladesoga.wordpress.com and update your bookmarks.

Friday, 4 September 2009

Selenium Remote cant start firefox session due to lock on file

I am sure you have on this page, because you have run into problem with selenium not been able to run due to a lock on some profile files. Yes, you know what the error is. I really found useful two blogs here and here. However, inas much as i don not want to repeat what has been saidin the blogs i would paste and quote what i found useful and explain a little bit more.

Preparing Firefox profile...

The source of the problem is in the *.rdf files inside the selenium server jar. The Selenium guys have hardcoded a version ceiling for Firefox at version 2.0.0.* (in my case it was 3.5.*). The fix is really simple.

Step 1: Extract the files needing change (from the directory where you have the jar). -

jar xf selenium-server.jar customProfileDirCUSTFFCHROME/
extensions/readystate@openqa.org/install.rdf
jar xf selenium-server.jar customProfileDirCUSTFFCHROME/
extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
jar xf selenium-server.jar customProfileDirCUSTFFCHROME/
extensions/\{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4\}/install.rdf
jar xf selenium-server.jar customProfileDirCUSTFF/extensions/
readystate\@openqa.org/install.rdf
jar xf selenium-server.jar customProfileDirCUSTFF/extensions/
\{538F0036-F358-4f84-A764-89FB437166B4\}/install.rdf

Step 2: Change the max version in the rdf (Resource Description Framework) files.

The line of interest looks like this: 2.0.0.*

* you can change this to 4.*, should buy some time.

Step 3: Update the jar with your changes.

jar uf selenium-server.jar customProfileDirCUSTFFCHROME/
extensions/readystate@openqa.org/install.rdf
jar uf selenium-server.jar customProfileDirCUSTFFCHROME/
extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
jar uf selenium-server.jar customProfileDirCUSTFFCHROME/
extensions/\{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4\}/install.rdf
jar uf selenium-server.jar customProfileDirCUSTFF/
extensions/readystate\@openqa.org/install.rdf
jar uf selenium-server.jar customProfileDirCUSTFF/
extensions/\{538F0036-F358-4f84-A764-89FB437166B4\}/install.rdf

That's it, once that's changed you should be good to go for testing against Firefox 3!

So that was a summary of what i found, but my case was a bit different as the version of firefox that was hardcoded in the selenium-server 1.0.1 was 3.5.* and my version of firefox was 3.5.2, so naturally i expected firefox to work for me. But as it did not work, as a trail and error, i changed the hardcoded version to 4.5.*. and voila it worked for me.

Also i did not use the jar uf command, what i did was to temporarily change the extension of the selenium server jar file to a .zip file and then i opened the zipped file created with winzip.

I then extracted the 5files which i need to amended to my desktop, amended the file with a text utility and then drop the files back into the zippped selenium server file. Lastly i changed the extensions back to .jar.

And it worked. i hope this works for someone as well

Monday, 13 July 2009

css selectors in place of xpath for selenium locators

yeah so in all these year, i have always resolved to using xpath whenever i am creating selenium scripts and i need to do stuff with element that have no id. well as you would probably know, xpath executes so slow on IE.

For intance i have a test suite that would run in 1hr 30mins on firefox/ safari but the same test suites would take over 4hrs to run to completion on IE.

So with the help of a colleagues, i have been using css selectors from last week and i can say this has drastically improved the speed of our test and you would notice too much difference between IE and FF/Safari anymore.

It takes some time to get used to but these are some link that might be useful to get start with ....

Enjoy .....

Thursday, 30 April 2009

Selenium Test execution speed on Safari vs Internet Explorer

I have been working on a selenium test suite that contains about 150 tests.
These test would normally take about 4hrs 30mins for it to execute to completion.

I tried to run same tests on Safari today, and it took exactly 1hr 9min. This is such a big difference 
and i think it is because of the extreme use of Xpath in the test suite. And as it is known thatXpath execute soooo slow in IE.

This is quite good as i have decided to run intraday tests in safari so as to get faster feedback, cos up until now i am unable to kick off these test because a test suite that takes 4hr 30min to executes would have taken almost half of my day and does little good.

I would be writing another post that talk about how to efficiently use Xpath in your tests whenever you need to ......


Any comments ............

Wednesday, 4 March 2009

Not able to accept meetings in Outlook



Need to say i got an error displaying on the invite: This meeting is not in the calendar, it may have been moved or deleted.

Discovered that when i click on the "Accept Button" for meetings which i have been invited, the Accept button doesn't do anything. The invite sent to me,looks like this :




Doing a bit of google got me this link, and it worked for me

Just incase the link goes down some day, here is what you need to do

1. Kill all services relating to Microsoft products (i.e. Word, Outlook, Messenger etc.)
2. Then from the Run line, enter "outlook.exe /cleanfreebusy".

Wednesday, 25 February 2009

Waiting for Elements in an IFrame on a WebPage to Load

Waiting for a page to load while writing selenium scripts is pretty straightforward using the
selenium.WaitForPageToLoad("timeout") timeout is time in millisecond.

Sometimes using this command doesn't work, especially when you the whole page is not loaded or reloaded but a popup is loaded in a div on the page. In situation like this i would used the
selenium.WaitForCondition("ScriptToReturnwhich ReturnTrue OrFalse", "timeout");
e.g. of scripts would be

selenium.WaitForCondition(selenium.browserbot.get CurrentWindow().document
.getElement ById('idOfElement ToBelocated')!=null", "60000");

This has always worked well for well until today, i had a special case where the element that i needed to wait for it to load was inside an IFrame, which is loaded within a parent page. Using the Wait for condition as above kept timing out as the Javascript could not access the IFrame.

what worked for me after several hours of trying is:

selenium.WaitForCondition("selenium.browserbot.getCurrent Window()
.frames['Name Of IFrame'].document.get Element ById
'idOfElement ToBelocated')!= null", "60000");


This brilliantly eliminated my nightmare .......

Comments are welcome

Saturday, 31 January 2009

Need to get a value of an attribute using selenium

I was in this situation when i needed to get the value of an html attribute and i found the selenium.getattribute very handy .....

Okay the scenario was such that there was an element which is collapsible on the page and the only attibute for that element that indictated the status of the collapsible element was the 'Class'. when the element was collapsed, the value of the class attribute was 'asleep' and when the element was expanded, the value of the class atttribute was 'awake'.

The script used to determine the status of this element is
selenium.GetAttribute("elementLocator@nameofAttribute");

so if the id of my element is FundingClass and the attribute we are interested in is the 'Class'

The selenium code will be
selenium.GetAttribute("FundingClass@Class");

Hope this helps someone .....

Tuesday, 23 December 2008

Using selenium.GetEval(script)to execute Javascript

The task at hand was to navigate through the DOM of a particular webpage and check the
style.display attribute of an object or element if you prefer. There are two elements on this page that displayed either success or failure messages.(msgSuccess and msgFailed)
For perfomance reasons, if previously a successful message was displayed and subsequently the you get a failure message, what the developers of the page did was to amend the style.display attribute.

<span style="display: none;" id="msgSuccess" class="MyMsgSuccess">

The HTML code above implies the element 'msgSuccess' would not be displayed

<span style="" id="msgSuccess" class="MyMsgSuccess">

In the second case, the msg success would be displayed ....

The problem i encountered was, sometimes i would have

< span style="display: none;" id="msgSuccess" class="MyMsgSuccess" > Operation Successful </span >

If i do a selenium.GetText("msgSuccess"), i get the text returned even though the style.display is set to none. Hence the need for the Selenium.GetEval to check the value of the style.display attribute as that seem as a true test for the web page

I have done:

const string script = "document.getElementById(\"msgSuccess\").style.display";
string evalResult = selenium.GetEval(script);

The above script failed as selenium was executing the javascript in the selenium console and not on the Application under test (AUT)
and searching the internet got me doing:

const string script = "selenium.browserbot.getCurrentWindow().document.getElementById(\"msgSuccess\").style.display";
string evalResult = selenium.GetEval(script);

This way i got the javascript to be run on the Application under test ....