Each day presents something new to learn.

The goal is to write at least once a month about topics that relate to my work - Enterprise Agility, Leadership, Entreprenuership, Personal Develop and Africa. My writings represents my opinions and it will change over a period of Time.

Active Record find by Column Name

In recent days been doing a lot of ruby, which means i tend to use Active Recordas well. I had written some scripts where i was selecting records that matched a criteria such as: @table1.table2s.select{|e| e.column_name == 1234} but as i need to sort my result and also give some more conditions to filter the data, i need alternatives to this above query and i ended up with the two lines of code below:

Regex for pipe "|" character

I was trying to split a string using a regex today and i had this problemmy string of formatA | B | CMy intent was to split this string using the Regex match for “|"The regex that worked for me was “\|” - escaping pipe and then escaping the slash the escapes the pipe

Workaround: Flash selenium test would not run in firefox 3.5 except when the browser mode is *firefoxProxy

I looked into flash seleniuma few weeks back and i thought it was a great way for me to test certain part of the apps i have been ignoring for some time.However after knocking up a few test i discovered that my test would not run in my version of firefox (3.5). I got this error:INFO - Got result: ERROR: Threw an exception: NPMethod called on non-NPObject wrapped JSObject! on session 471c65508e46457fa43f4deb873d0592Then i read in some issueraised in the flash selenium site that flash selenium would only work in firefox 3.

Search for a single digit within a string using regex as provided in java api

In my current work, i have been writing a lot of test in Java, which obviously means i need to learn a lot more about the Java api, which is good i think?????Well i needed to match the single digit in this string “home-area-1” and return this digit. With a quick google i found this piece of code here.Pattern p = Pattern.compile(“ab”);Matcher m = p.matcher(“aaaaab”);boolean b = m.matches();System.out.println(b);A quick run of this code printed “true” which means the code works.

Start the Selenium Server dynamically

I have been working on a test suite in java using testng as the testing framework. I could not have suggested any other test frame work as it allows me to do a lot of configurable setups and teardowns. Yeah am not gonna promote testng anymore, lol.I could have started using selenium server using a usual batch file that maven could call in one of its targets but i think doing it this way is cleaner.

css selectors in place of xpath for selenium locators

I have always resolved to using xpath whenever i am creating selenium scripts and i need to do locate elements with 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.

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 thislink, and it worked for meJust incase the link goes down some day, here is what you need to do1.

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’.

Internet Explorer doesnt handle xpath to locate images exceptionally well

So i have been doing a lot of selenium and the website i am trying to automate test fordoesnt have a lot of element with id, name, or any other HTML attributes that makes selenium testing a bit easier.So i have been using of xpath, my intent was to click on an image and i have used the src attribute of the image element.so my original command,selenium.click (“xpath=//img[@src="location/of/image/on/disc”]");This works excellently on firefox but on IE, i keep getting the error “Element not found!

Use selenium to create screenshot

I just stunbled across selenium as a tool to take screenshot.Thuis could be useful for anything.In my case i used it to take the screenshot of a page just before it throws an error in my selenium test. and that i could have a look and investigate what the problem might have been.very simple command and the great thing is it can be easily used for screenshots of a page across different browsers.