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

Friday, 3 September 2010

A tester's reflection on kanban plus BDD

So i have just finished an engagement with a client where the development process used include
kanban and BDD. Kanban for us meant that we give priority to work on the right side of the board.
So as a tester, I would rather spent my time doing some manual testing on a story that is in the QA queue, than writing automated acceptance tests for a stroy in the queue for Accetance Tests.

Maybe it would be worth while to draw a representation of the way in which work flows through our kanban board

Analyis > Queue > Accetance Tests in Progress > Queue > Dev in progress > Queue > QA in progress > Smoke Test > Queue > UAT Deployment in progress > Queue > UAT in progress > Queue > Live Deployment in Progress > Deployed.

The good thing is that everyone in the team has a visibility of work up till deployment. For more information, read up kanban

The BDD framework used was Cucumber + Watir + Rspec, and developers would only start developing software when the tests have been written for the acceptance criteria. (Acceptance criteria is written by Analysts in a text editor in the cucumber format). The acceptance tests is jointly owned by developers and testers. If as a tester i am busy doing some other tasks further down in the work flow, the developers were happy to write the failing automated test for the acceptance criteria before development commences.

As a result of these good practices:

1. The team was always in good spirit and which improves the effectiveness
2. The number of defects raised was low, this was achievable because for a developer to move a story to the QA queue, the automated acceptance criteria must have been passing.
3. There wasnt a defect management system because testing is carried as close to the development time, and if the business believes the defect is critical to the functionality, the functionality of story does not progress further in the kanban board, but it is blocked until fixed and verified.

One downside is that because we wrote acceptance test for virtually every functionality that is testable, the acceptance test grew so quick that the time taken increased from about 20mins to about 1.40mins and this time kept growing. A side defect of this is that feedback time increased and as a result developers would not run the complete test suite before checking their code in. This was however managed by doing some exploratory manual testing around the functionality being developed.

All in all, it was a good experience for me and i just hope i get to work on more projects such as this.

Friday, 25 June 2010

Watir: Search for elements on page using multiple attributes

I ran into a situation today where i wanted to scan through a page and return a table based on the table matching 3 attributes

Before:

browser.tables.find do |table|
table.class_name == 'my_class_name' and
table.cell(:class, 'class_1_name').text == 'some_text_1' and
table.cell(:class, 'class_2_name').text == 'some_text_2'
end

This was taking about 3minutes as there were about 86tables on this page under test. I was worried but the tables on this page was gonna increase with time which meant the time for this stage of the test was bound to increase.

In my search for how to search for a single table using multiple attributes:

I found this:

After:

browser.table(:class => 'my_class_name', :text => /#{'some_text_1}/, :text => /#{'some_text_2}/)

Believe it or not, i got my test time reduced to 3secs, awesome isnt it?

Enjoy!!!!!!

Friday, 23 April 2010

Implement 'Select column_name from table_name where condition' in Active Record

I need an array from the data contained in a particular database column based on a condition, so i get the array of active record rows:

array_of_rows = TableName.find(:all, :conditions => {:column_name => ['col_data1','col_data2']})

Then use the array map! function to replace the active record objects with the column_name value
array_of_rows.map!{|item| item.column_name}

Doing some search got me:

array_of_rows = TableName .find(:all,:select=>'column_name' :conditions => {:column_name => ['col_data1','col_data2']}).map(&:column_name)

And i like this better, concise ....
update:

I've had to update the active record query above by removing the :select option

array_of_rows = TableName .find(:all, :conditions => {:column_name => ['col_data1','col_data2']}).map(&:column_name)

This is because if i have a method

def find_some_data
TableName .find(:all,:select=>'column_name' :conditions => {:column_name => ['col_data1','col_data2']})
end

I am able to do:

find_some_data.map(&:column_name)

but i cannot do

find_some_data.map(&:another_column_name)

throws: missing attribute: another_column_name (ActiveRecord::MissingAttributeError)

because i have only retrieved 'column_name' values from the table

In other to be able to create any array composed of data from any column_name, i have

def find_some_data
TableName .find(:all, :conditions => {:column_name => ['col_data1','col_data2']})
end

Tuesday, 6 April 2010

Active Record find by Column Name

In recent days been doing a lot of ruby, which means i tend to use Active Record as 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:

@table1.table2s.find(:all, :conditions => {:column_name => 1234})
@table1.table2s.find_all_by_column_name(1234)

Please note that the two lines above does same thing, the second one is just a lil but shorter and more readable the the 1st one.

using the second one i can now do stuff like

@table1.table2s.find_all_by_column_name(1234, :order => "col_2 ASC")

which would order my results based on the column that i have specified and i could have ASC - ascending and DESC - descending.

I have learnt something else today .... Have you?

Monday, 23 November 2009

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

I looked into flash selenium a 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 471c65508e46457fa43f4deb873d0592
Then i read in some issue raised in the flash selenium site that flash selenium would only work in firefox 3.0 and it worked fine in IE for me.

Today while i was investigating another issue, i decided to try running the flashSelenium test in the "*firefoxproxy" mode and my tests ran succcessfully.

I am sure this workaround would be welcome by people facing this issue as well, please leave a comment if this is any help.

Thanks




Wednesday, 18 November 2009

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("a*b");
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.

So i wrote this:

Pattern p = Pattern.compile("[1,2,3,4]");
Matcher m = p.matcher("promo-area-3");
System.out.println(m.group());

and guess what this fails ...... giving me an "illegal state exception"

Pattern p = Pattern.compile("[1,2,3,4]");
Matcher m = p.matcher("promo-area-3");
boolean b = m.matches();
System.out.println(b);

This returns false which suggests that matching is not working properly.

After a lot of guesses and try and errors , i did

Pattern p = Pattern.compile("[1,2,3,4]");
Matcher m = p.matcher("promo-area-3");
while (m.find()) {
System.out.println("regex stuff " + m.group());
}

My thinking is this, the first code with this pattern "Pattern.compile("a*b");" was searching for a text which the subsequent one "Pattern.compile("[1,2,3,4]")" was a search for a character within a sequence and maybe this account for the while loop with m.find ........

Am not sure, maybe if anyone has a better explanation ... i would appreciate

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

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

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

Saturday, 8 November 2008

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 for
doesnt 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!"

so after several tries, this definitely work on both IE and firefox ......

selenium.click ("xpath=//img[@contains(@href, "google.com")]");
The second parameter of the xpath "contains" a segment of the link that the image element points to.Note that the img element has a href and that is why i am able to use the "contains" method of the xpath to locate the img.

Thursday, 6 November 2008

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.

browser.CaptureEntirePageScreenshot("C:\\actual _path_to_where_you_want the_file _placed\\screenshot.png");

Monday, 3 November 2008

Selenium: Xpath locator can not be used as Option Locator

In my new job been doing a lot of selenium and i needed to scroll through the list of
options in a select element and click on a particular options.

i have initially used the browser.DoubleClick

browser.DoubleClick("xpath=//select/option[child::text()='Option_Label']");)

But then this didnt work because selenium doesn't have the functionality to scroll down the select element in other to make my desired option visible.

Looking through the selenium api, i have used another method, which take in two parameters, the select locator and the option locator.

so i used:

browser.Select("xpath=//select", "xpath =//option[child::text()='Option_Label']");

that hasnt work either as the option locator type cannot be xpath. it has to be a label, id, atrribute, name or any other html locator

so i have done

browser.Select("xpath=//select", "label=Option_Label");

which in myown opinion i think is good as it is robust for a selenium test.