Archive | Test tool RSS feed for this section

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

[Selenium Tutorial] Selenium Grid Overview

3 Dec

This slide will provide for us overview about selenium grid basically

– What is Grid?
– What is Grid Computing
– Selenium Grid
– Selenium Grid Architecture

I got this from Internet

Copyright by Kangeyan Passoubady (Kangs)
Link download: Link

[Slide] Selenium Tutorial – How to Install Selenium RC – step by step

6 Jul

This document will help you to setup Selenium RC

– JRE 1.5 or later
– Selenium RC Server
– Ruby Selenium Client
– Try to run an example with Ruby Test

(Source from Internet)

You can download in link
There are more slides about Selenium Tutorial, I will upload later.

Hold a small tutorial group to learn Selenium

21 Jun

Hello everyone,

I am beginner in investigating about Selenium, so I’d like to hold a small group with everyone who likes to investigate Selenium like me or who had already experience with Selenium and want to share your knowledge. If you are interested in, please register by commenting in here or sending email to me mycollection.online@yahoo.com with information as below
– Your name
– Your email
– Your experience about Selenium
– How many hours can you spend to investigate about Selenium per a week?

What you can get after we finish this investigation,
1. Learn how to work with a team and learn by yourself
2. Learn how to make presentation, write guideline in English
3. Get knowledge about Selenium in short time
4. Have new friends around the world

Let’s join together ^^

I expect our project will start from the beginning of July 2012 and ending about Nov 2012 depends on the number of registered persons. I will share detail plan after receiving your registration. Hope that we can cooperate to share knowledge about Selenium together.

Learn to share and share to know more ^^
12

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] Tutorial document about advanced Selenium

9 Jun

What This Session Covers
1. Selenium’s scope
2. TestRunner techniques
3. Remote Control
4. Ajax
5. IDE
6. Extensions
7. Best practices

This document is so useful if you want to learn detail about Selenium.

Source from http://therichwebexperience.com
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