Wednesday, October 29, 2014

Love Your Solitude

“Therefore, dear Sir, love your solitude and try to sing out with the pain it causes you. For those who are near you are far away… and this shows that the space around you is beginning to grow vast.

Be happy about your growth, in which of course you can’t take anyone with you, and be gentle with those who stay behind; be confident and calm in front of them and don’t torment them with your doubts and don’t frighten them with your faith or joy, which they wouldn’t be able to comprehend.

Seek out some simple and true feeling of what you have in common with them, which doesn’t necessarily have to alter when you yourself change again and again; when you see them, love life in a form that is not your own and be indulgent toward those who are growing old, who are afraid of the aloneness that you trust.

And don’t expect any understanding; but believe in a love that is being stored up for you like an inheritance, and have faith that in this love there is a strength and a blessing so large that you can travel as far as you wish without having to step outside it.”

Letters to a Young Poet.

 Rainer Maria Rilke

Tuesday, October 21, 2014

Upload File In Selenium Webdriver In C#

Many web applications contain HTML forms which interact with the user. The user is able to enter data in to the form fields and submit the data to a server. Selenium is able to handle form inputs such as entering text in text fields, selecting radio buttons, selecting a value from a drop-down menu and so on. Things get a little tricky when dealing with input form fields of type “file”, to allow users to browse for a file and attach the file to the HTML form and submit the file.

We can upload file in selenium webdriver easily. We have to just find the element with file control, open the widow popup, select the file and then set the value of document we want to upload in it.

Complete example in C#.Net to upload the document using selenium webdriver.

using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.PageObjects;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

public class UtilityManageRateSheetsPage
{
public void UploadFile(string fileToUpload)
        {           
                //Open window popup
                IWebElement upload = Browser.WebDriver.FindElement(By.XPath("/html/body/div[2]/div/table/tbody/tr[1]/td[3]/div/form/input[1]"));                       
                Actions actions = new Actions(Browser.WebDriver);
                actions = actions.MoveToElement(upload);
                actions = actions.Click();
                actions.Build().Perform();
                System.Threading.Thread.Sleep(1000);
                //Select the file
                System.Windows.Forms.SendKeys.SendWait(fileToUpload);
                System.Windows.Forms.SendKeys.SendWait("{ENTER}");
                System.Threading.Thread.Sleep(1000);
                //Click import button
                Browser.WebDriver.FindElement(By.XPath("/html/body/div[2]/div/table/tbody/tr[1]/td[3]/div/form/input[2]")).Click();
                //Wait for the file to be uploaded
                 System.Threading.Thread.Sleep(10000);  
       }

}

Monday, October 20, 2014

Test Automation using C#, Selenium WebDriver and NUnit

What is Selenium?
Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

Selenium IDE is an integrated development environment for performing Selenium tests.  Selenium tests can be written as HTML tables or coded in various languages like C#, PHP, Perl, Python and can be run directly in most modern browsers.The IDE can help you to record, edit and debug tests. Currently the IDE is only available for Firefox (as if we developers will use any other) as a addon.
Here is a possible scenario for using Selenium. Imagine you have created a HTML form with about twenty fields and you have to repeatedly test the form. Filling the form every time can quickly become tedious. With Selenium you can automate the whole process and run the test as required. In this part we will see how to create a simple test in Selenium. So let’s get started.

Creating a Test Automation Framework is a challenging task due to following reasons:

Test framework design and the coding of that design requires significant time and effort
Test framework must be easy to expand and maintain
Test framework should be independent of application
Test design should remove most testers from the complexities of the test framework

SOFTWARE REQUIREMENTS:

Windows 7 as OS
Microsoft Visual Studio 2013 as IDE
SpecFlow as BDD tool for .Net
NUnit as Unit Testing Tool
Selenium as a Test Automation Tool

Basic Architecture:
I have developed test framework for test automation using selenium which can be over viewed as shown below.

 Page-Object pattern:
Test code is easily readable.
Distinguished reusable code.
No duplication of Selenium API calls.
Creation of tests are easy and improves maintainability.
Used effectively with IDE such as Visual Studio, Eclipse, IntelliJ, Visual Studio.
Excellent support for languages such as C#, Java, Ruby, Python, Perl.

Test Framework Code Overview.
Application Test code hierarchy which categorized the tests for each application and its releases.



A Very Simple Test for Utility App:
Simple understandable test cases using page objects. 

Popular Posts