Tag Archives: Test

Some links for intergrating Jenkins for Selenium

26 Aug

http://www.learn-automation.com/p/jenkins-for-selenium.html
http://www.browserstack.com/automate/continuous-integration
http://www.ontestautomation.com/running-selenium-webdriver-tests-in-jenkins-using-ant/

They are so useful

Unit Testing and Test Automation in VS2012 Part 2: Integrating Selenium with Visual Studio

4 Jul

In the first part of this series we discussed about integrating NUnit with Visual Studio 2012. One of NUnit’s strong points is its extensibility which has been used to expand unit testing even further — as far up as the user interface in fact. This is where Selenium comes in.

Selenium runs on top of NUnit so that it can run tests against instances of web browsers. With the new testing features of Visual Studio 2012 we can now use it to test web applications.

If you haven’t read the first part of this series and haven’t followed the steps given there, I suggest reading it now and following the steps to install NUnit on Visual Studio 2012 first. They are a prerequisite to the next steps in this article.

Integating Selenium into Visual Studio 2012

Since we’ve already integrated NUnit to our Visual Studio solution, why not go all the way and use Selenium as well? Selenium uses the NUnit Framework for its tests anyway — it’s just a matter of adding several more components to allow Selenium’s Webdriver to fire up a web browser and start executing tests.

To do this we need to extend our project a bit:

  1. Open up the Manage NuGet Packages window again (right-click on References under the project -> Manage NuGet Packages) and in the search box type “Selenium”
  2. Select “Selenium Webdriver” and click Install to add Selenium references to your project.
  3. Select “Selenium Webdriver Support Classes” and click Install — these are some additional references necessary to run Selenium tests in your Visual Studio solution.
  4. Download IE Webdriver from the Selenium download page (choose the appropriate 32 or 64 bit version) and unzip.
  5. Righ-click on the project name and click “Add existing item…”
  6. Browse to the folder containing IEDriverServer.exe and choose that file to add to the project
  7. Under the project tree right-click on the file and click Properties
  8. Set the value of the field “Copy to Output Directory” to “Copy if newer”

The steps regarding the web driver ensure that the exe required to open up a browser is always copied to the /bin/Debug folder, from where it will in turn be used to call on the browser executables and open up the browser.

We can use the project we already set up above to test this. Add a new class and set it to have the following code. Note the additional OpenQA using declarations, aside from the NUnit.Framework that we’ve used before:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
namespace TestAutomation
{
    [TestFixture]
    public class Driver
    {
        IWebDriver driver;
        [SetUp]
        public void Setup()
        {
            // Create a new instance of the Firefox driver
            driver = new InternetExplorerDriver();
        }
        [TearDown]
        public void Teardown()
        {
            driver.Quit();
        }
        [Test]
        public void GoogleSearch()
        {
            //Navigate to the site
            driver.Navigate().GoToUrl("http://www.google.com");
            // Find the text input element by its name
            IWebElement query = driver.FindElement(By.Name("q"));
 
            // Enter something to search for
            query.SendKeys("Selenium");
 
            // Now submit the form
            query.Submit();
 
            // Google's search is rendered dynamically with JavaScript.
            // Wait for the page to load, timeout after 5 seconds
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
            wait.Until((d) => { return d.Title.StartsWith("selenium"); });
 
            //Check that the Title is what we are expecting
            Assert.AreEqual("selenium - Google Search", driver.Title);
        }
    }
}

Run the tests again. The test should open Internet Explorer and then open up Google. The result in the Test Explorer would look like this, just like our NUnit test:

Conclusion

With the capability to tightly integrate NUnit and Selenium in Visual Studio 2012 solutions and projects, Microsoft redeems itself by rectifying the ghosts of MSTest: it brings unit testing much closer to coding, it finally allows test-first/test driven development, and it opens up the capability for third-party unit testing frameworks to run in Visual Studio as first class citizens. This allows other open source testing frameworks like xUnit.net, QUnit/Jasmine, and MbUnit to run seamlessly with Visual Studio 2012.

References

I’d like to point out Anoop Shetty’s blog post on Selenium integration from which I took the steps and code for the Selenium test used in this post. While his post was applicable to Visual Studio 2010 the steps were practically the same for Visual Studio 2012.

Unit Testing and Test Automation in VS2012 Part 1: Running NUnit natively in Visual Studio

4 Jul

One of the most criticized features of Visual Studio ever since it came out has been the ability, or lack and inadequacy thereof, of the IDE to integrate third-party unit testing libraries into it. MSTest was not only too late but was also too lame — it wanted users to rely on automatically generated tests put up after code has already been written. This runs so counter to the tenets of Test Driven Development that MSTest was simply ignored, and many developers came up with ways to hack third party unit-testing frameworks like NUnit, MBUnit, xUnit and so on for their .NET projects. Inevitably, Microsoft and MSTest ended up being vilified by the believers of TDD.

With Visual Studio 2012 Microsoft provided a means of using frameworks like NUnit and Selenium to actually be run within its IDE, in a tightly integrated way, and in turn, the ability to code test-first.

Let’s talk about how to make that happen.

Setting up the NUnit Test Adapter

First in our agenda is to wire Visual Studio 2012’s testing framework to NUnit. To be able to do this we need to download and install the NUnit Test Adapter extension, which we will do via Visual Studio’s “Extension Managers” feature:

  1. With Visual Studio 2012 started, go to the Tools Menu and click on Extensions and Updates
  2. On the left tab click on “Online” and on the Search field on the upper right type in “NUnit Test Adapter”. You will need an internet connection for this to work.
  3. When the NUnit Test Adapter item appears click the “Download” button. Once the download is complete follow the instructions to install the NUnit Test Adapter
  4. At the bottom of the window you may be asked to click “Restart Now” to allow the newly installed components to take effect within Visual Studio 2012.

Once you’ve finished this Visual Studio 2012 is now ready to run NUnit tests within the IDE.

Creating your first NUnit test project

Let’s now create our first NUnit test project.

  1. Go to File -> New -> Project and under Visual C# choose “Class Library” and rename to “NUnitTestDemo”. You may also want to rename your “Class1.cs” into something more sensible.
  2. In the Solution Explorer right-click on references then click “Manage NuGet Packages”.
  3. On the left tab click on “Online” and then on the Search field type “NUnit” this time. When the result appears click “Install”.

All the relevant classes required for NUnit should now be included in the project — it’s now time to write some unit tests!

Our bare code so far looks like this (I’ve renamed the project “NunitTestDemo” and the default class “FirstUnitTest”):

1
2
3
4
5
6
7
8
9
10
11
12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NunitTestDemo
{
    public class FirstUnitTest
    {
    }
}

To check if NUnit works on Visual Studio let’s try adding bits of code and one dummy test:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
namespace NunitTestDemo
{
    [TestFixture]
    public class FirstUnitTest
    {
        [Test]
        public void TrueTest()
        {
            Assert.IsTrue(true);
        }
    }
}

To run this test, click on the Test menu, Run, then All Tests. You could also use the shortcut Ctrl-R, then A.

The test result under the new “Test Explorer” tab will look like this:

Details like the name of the tests and execution times of both individual and all tests appear in this tab.

Let’s add a failing test just to see what it looks like:

1
2
3
4
5
[Test]
public void MathTest()
{
    Assert.AreEqual(0, 1 + 1);
}

Running the tests again, the result would look like this:

Additional details come up — highlighting the failed test reveals the expectations of the failing test, the actual result, and even the stack trace, crucial for figuring out why the test is failing.

You’re now ready to use NUnit to code test-first for your classes.

But you could also use it for your front-end code, particularly web applications. On the next installment of this 2-part series I’ll show you how to use Selenium for front-end testing in Visual Studio.

References

Peter Provosts’s presentation on Visual Studio 2012 unit testing features in TechEd Europe was a crucial reference for this post.

how to set up an environment and test Android application using Selenium

19 Jun

Android WebDriver allows to run automated end-to-end tests that ensure your site works correctly when viewed from the Android browser. Android WebDriver supports all core WebDriver APIs, and in addition to that it supports mobile spacific and HTML5 APIs. Android WebDriver models many user interactions such as finger taps, flicks, finger scrolls and long presses. It can rotate the display and interact with HTML5 features such as local storage, session storage and application cache.

We try to stay as close as possible to what the user interaction with the browser is. To do so, Android WebDriver runs the tests against a WebView (rendering component used by the Android browser) configured like the Android browser. To interact with the page Android WebDriver uses native touch and key events. To query the DOM, it uses the JavaScript Atoms libraries.

This link is good to learn how to setup and test Android app using Selenium

http://code.google.com/p/selenium/wiki/AndroidDriver

Tips for ISEB and ISTQB exams

5 Dec

Just read a good link, so want to share it to everyone who want to get ISTQB certificate.
Hope that I have much free time in next year to learn and take this exam
——————————————————-
Introduction
I would like to share with you my experience with the exam. The opinions presented in this article are my personal thoughts, feelings and ideas.

Let’s not go into debate if certification is needed and if it has real benefits. For arguments pro certification you can check http://www.testingexperience.com/testingexperience01_08_Black.pdf  and for arguments against you can refer to http://www.satisfice.com/blog/archives/36. The choice is yours.

After Foundation Level, you need to choose certification path ISEB or ISTQB. I took ISTQB since having advanced level with 3 specializations makes sense from carrier development point of view and the path Foundation -> Advanced seems to be straight forward. The Expert level created recently with 4 specialities seems to be over the top. You can read more about the ISTQB certification path here: http://istqb.org/display/ISTQB/Certification?atl_token=93VdaeFKJJ

ISEB tries to split hair in four with Foundation->Intermediate->Practitioner->Advanced levels. I think, it’s too much effort to get to advanced level. More about ISEB certification path can be found here: http://www.bcs.org/server.php?show=nav.10920. And actually ISEB has announced recently that Practitioner Level certification will be possible only till 15 March 2010 and they switch to ISTQB certification only. There is one, quite nasty effect of such solution. Nowadays you can see mistakes in job offers like ISTQB Practitioner level required. Who is going to tell which Advanced certificate you have? ISEB or ISTQB? So in most of cases you will have to defend yourself that you have chosen longer certification path.

I have passed exam for ISEB Certified Tester Foundation Level and ISTQB Certified Tester Advanced Level – Test Manager exams, so I will write a bit about both levels.
Preparation for exam

First of all for every exam you need to prepare. Question about preparation is the most asked one. Some people say that you don’t need any preparation, others say that you can not pass the exams without proper training.

What is my opinion?

From my experience I can tell you, that answer to that question is tricky. For the Foundation Level the syllabus provided by the organization should be enough as source of theoretical knowledge, but … Reading book about testing in general, like Software Testing by Ron Patton is highly recommended. Professional experience as a tester can both help you and disturb you. Why? That depends on terminology and methods used on the projects you took or take part in. If on the project everything is set-up and named according to ISEB/ISTQB syllabus and vocabulary, exam should be easier for you, you can refer to “how do we do that on the project?”. If not, you will be very confused and the referring to “how do we do that on the project?” will just fool you. Preparing for foundation level, you don’t need to worry much about the Reading List at the end of syllabus.

Don’t forget to read vocabulary and learn the terms that are in there. Look at these simple questions: what is Test Case and what is Test Procedure, what’s the difference between them? Did you get it right? It’ s very easy to give a wrong answer if you are confused by terminology.

If you are not sure about following the standard on the project, go for training. Then you should have clarity and your knowledge will be ordered.

There is big question about self-preparation. Are you really going to seat and learn in the evenings and weekends? If not – better go for training.

With preparation for Advanced Level, the case is even more complicated. The Syllabus is for sure not enough. It looks more like set of guidelines, description of scope. Experience from projects can help you, but whatever is your experience, most probably you are not familiar or you simply don’t remember all test process improvement methods and all software development methodologies, frameworks. Going for training is definitely a good idea.

Full certificate is split nicely into three parts with a reason. It’s a lot of material to learn and understand, especially for Technical Test Analyst module. It’s better to prepare to and pass them one by one.

When you study, a good idea is to make notes in form of Mind Maps. I find this form very useful and easy especially for quick refreshing of my knowledge.

For Advanced Level Test Manager, there are few books that can be used for preparation

The yellow one – Software Testing Practice: Test Management: A Study Guide for the Certified Tester Exam ISTQB Advanced Level by Andreas Spillner, Tilo Linz, Thomas Rossner, and Mario Winter

The black one – Advanced Software Testing – Vol. 2: Guide to the ISTQB Advanced Certification as an Advanced Test Manager by Rex Black

The green one – Guide to Advanced Software Testing by Anne Mette Jonassen Hass

I can recommend you the green one. It worked for me really well.

For the two Analyst modules we have a similar set:

The Software Test Engineer’s Handbook: A Study Guide for the ISTQB Test Analyst and Technical Analyst Advanced Level Certificates by Graham Bath, et al.

Advanced Software Testing – Vol. 1: Guide to the ISTQB Advanced Certification as an Advanced Test Analyst by Rex Black
General tips and tricks for exam
1. The best and most successful trick is: do the study or go for training or do both.

2. For both ISEB and ISTQB you can find example exam questions in the internet. It is wise to take these exams and get used to the form of questions.

3. Studies show that when you have answered a question and you change the answer because you are not sure – usually you change it to wrong one.

4. Having the exam on the last day of training is not very good idea. You can be brain-fried and it will be difficult for you to focus and understand questions. But don’t postpone the exam for longer that 2 weeks – then most probably part of the knowledge acquired on the training will be vanished and in practice you can start studying all over again.

5. Questions are quite long, often describing specific situation on the project, so useful thing is to highlight/underline the question itself and highlight the most important context of the situation i.e. safety critical/non-safety critical. Always search for keywords. Why is it so important? Because in the text there are introduced so called distractors. And as you can guess, the role of distractor is to bring your focus and attention to the least important information.
6. There are no negative points for incorrect answers. If you really don’t know the answer, feel free to guess. In worst case you will get 0 points.

7. You don’t have to answer questions in order. First go through the examination sheet and answer to questions, you are sure about. For questions where you have doubts mark the most likely answer on the side of page or just move to the next one. Mark that page with some sign like question mark to find it easily later. Why to use such a technique? Because if you are short on time you can just guess answers to the rest of questions having questions you were sure about answered.

8. Roman Type questions – it is a variation of multiple-choice question. You have presented several statements in an ordered list marked with letters or Roman numerals (thus the name). Your task is to chose the right combination of true statements. Let’s see an example:

Which of the following answers reflect when Regression testing should normally be performed?

1) B & D are true, A, C & E are false
2) A & B are true, C, D & E are false
3) B,C & D are true, A & E are false
4) B is true, A, C, D & E are false

How to deal with that type of question? At the first glance they look like you have choice of 4 answers, what seems to be difficult. But

you can lower number of options by selecting 100% right and 100% wrong options. In the example above A, C are bold statements and are 100% false, therefore options 2 and 3 can be excluded.

A. Every week
B. After the software has changed
C. On the same day each year
D. When the environment has changed
E. Before the code has been written

1) B & D are true, A, C & E are false
2) A & B are true, C, D & E are false
3) B, C & D are true, A & E are false
4) B is true, A, C, D & E are false

We have 2 options now. B is in both, so it’s clear that Regression Testing should be done after the software has changed. What about environment? Environment can also influence results of testing because it’s changing the Test Conditions, therefore B and D are true, so the correct answer is option 1.
Foundation Level
1. On foundation exam you need to pay attention to previous questions. Sometimes answer to current question is in the stem of the previous one.
2. Quite a lot of questions contains parts of even whole sentences from Syllabus.
Advanced Level
1. At least in exams provided by GASQ questions are marked with level of difficulty and have weights K1 – 1 pts, K2 – 2 pts, K3 – 2pts. So if you have choice where to spend more time, go for K2 and K3 questions.
Conclusion

And that would be it. Pick you certification path. If you are just starting, better go for ISTQB path, which has future and takes less effort. The choice of taking training or not is yours. I hope you find this article helpful and have something to base your decisions on.

Good luck on exam!
Resources

http://www.academictips.org/acad/multiplechoiceexamstips.html
http://www.eviltester.com/index.php/2008/02/06/my-notes-on-how-to-study-…

———————————–
Source: http://kaczor.info/pl/node/73

How to write effective GUI test automation code using Selenium and Java

12 Jun

Just searching on Internet and got this document. In this presentation, you can get some useful information about how to write effective GUI test automation code using Selenium and Java

1. Introduction: What’s Selenium
2. What we achieved
3. 7 good practices using Capture Replay Tools

– GUI element repository.

– Division of data and script.
– Model the test objects.
– Establish standard functions and methods using “speaking” names.
– Central management of environment information.
– Divide common from project specific stuff. Use layering.
– Generate a useful test report
4. What’s missing in Selenium and how we closed the gap
5. Forecast

You can download in link

[Slide] Automated Web Testing with Selenium for beginners

6 Jun

You can find useful information for this presentation.

1. What is Selenium?

– Test tool for web applications
– Runs in any mainstream browser
– Supports tests in many languages
– Selenese (pure HTML, no backend required)
– Java, C#, Perl, Python, Ruby
– Record/playback (Selenium IDE)
– Open Source with corporate backing
– Lives at selenium.openqa.org

2. Demo

– Record a test in Selenium IDE
– Show same test written in Java

You can download in link

Source from Erik Doernenburg, ThoughtWorks

List of ebooks about selenium you should read

5 Jun

1. Selenium 1.0 Testing Tools: Beginners Guide

The Selenium Testing Tools Beginner’s guide shows developers and testers how to create automated tests using a browser. You’ll be able to create tests using Selenium IDE, Selenium Remote Control and Selenium 2 as well. A chapter is completely dedicated to Selenium 2. We will then see how our tests use element locators such as css, xpath, DOM to find elements on the page.

Once all the tests have been created we will have a look at how we can speed up the execution of our tests using Selenium Grid.

A beginner’s guide to writing Selenium tests using different aspects of the Framework to give you confidence in your web application

Test your web applications with multiple browsers using the Selenium Framework to ensure the quality of web applications

2.  The 2nd edition of “Selenium Simplified

“Selenium Simplified” takes you through the process of installing and learning to use all the basic tools needed to write automated tests using Java as the programming language. Written in a tutorial style, this book helps you learn to code even if you haven’t programmed before. No time is wasted on the theory of automation or padding about the tools. This book focuses on the practical knowledge needed to automate tests for production systems.After reading this book you will be able to: -Write tests in Java – even if you haven’t coded before reading this book-Install and maintain all the free development and testing tools covered within: Eclipse, JUnit, Selenium, Hudson, Subversion, Xpather, Selenium-IDE-Write automated tests scripts using Java and Selenium-RC-Create abstraction layers to make your automated tests maintainable and readable-Run your automated tests under continuous integration-Use multiple browsers to execute your tests-Understand the most utilised commands in the Selenium API-Test Ajax based web applications-Use Xpath and CSS Selectors in your tests-Understand how to optimise and refactor your tests-Use JUnit for data driven testing.

3. Java Power Tools

All true craftsmen need the best tools to do their finest work, and programmers are no different. Java Power Tools delivers 30 open source tools designed to improve the development practices of Java developers in any size team or organization. Each chapter includes a series of short articles about one particular tool — whether it’s for build systems, version control, or other aspects of the development process — giving you the equivalent of 30 short reference books in one package. No matter which development method your team chooses, whether it’s Agile, RUP, XP, SCRUM, or one of many others available, Java Power Tools provides practical techniques and tools to help you optimize the process. The book discusses key Java development problem areas and best practices, and focuses on open source tools that can help increase productivity in each area of the development cycle, including: Build tools including Ant and Maven 2 Version control tools such as CVS and Subversion, the two most prominent open source tools Quality metrics tools that measure different aspects of code quality, including CheckStyle, PMD, FindBugs and Jupiter Technical documentation tools that can help you generate good technical documentation without spending too much effort writing and maintaining it Unit Testing tools including JUnit 4, TestNG, and the open source coverage tool Cobertura Integration, Load and Performance Testing to integrate performance tests into unit tests, load-test your application, and automatically test web services, Swing interfaces and web interfaces Issue management tools including Bugzilla and Trac Continuous Integration tools such as Continuum, Cruise Control, LuntBuild and Hudson If you area Java developer, these tools can help improve your development practices, and make your life easier in the process. Lead developers, software architects and people interested in the wider picture will be able to gather from these pages some useful ideas about improving your project infrastructure and best practices.

 

 

 

How to setup and run Java Test tool (junit, emma) for beginners

5 Jun

Searching on Internet and find a useful slide for beginners with Java Test Tool

JUnit is a testing harness for unit test

Emma is a code coverage tool

You can find how to setup and run these test tool in this slide.

It is simple and easy to apply. Enjoy it by yourself

You can download in link

Efficient JavaScript unit testing (Video + Slide)

2 Jun