Friday, November 14, 2014

.NET Framework Overview Training Session

Table of Contents: Training
1.What is .NET?
Microsoft .NET platform architecture
2.What is .NET Framework?
.NET Framework Architecture
3.Common Language Runtime (CLR)
4.Managed Code
5.Intermediate Language MSIL
6.Assemblies and Metadata
7..NET Applications
8.Common Language Infrastructure (CLI) and integration of different languages
Common Language Specification (CLS)
Common Type System (CTS)
9.Framework Class Library
10.Integrated Development Environment Visual Studio


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. 

Monday, September 29, 2014

Famous Failures: Never Give Up!

Success comes in all shapes and colors. You can be successful in your job and career but you can equally be successful in your marriage, at sports or a hobby. Whatever success you are after there is one thing all radically successful people have in common: Their ferocious drive and hunger for success makes them never give up.
Successful people (or the people talking or writing about them) often paint a picture of the perfect ascent to success. In fact, some of the most successful people in business, entertainment and sport have failed. Many have failed numerous times but they have never given up. Successful people are able to pick themselves up, dust themselves off and carry on trying.
I have collected some examples that should be an inspiration to anyone who aspires to be successful. They show that if you want to succeed you should expect failure along the way. I actually believe that failure can spur you on and make you try even harder. You could argue that every experience of failure increases the hunger for success. The truly successful won't be beaten, they take responsibility for failure, learn from it and start all over from a stronger position.
Let's look at some examples:
Henry Ford - the pioneer of modern business entrepreneurs and the founder of the Ford Motor Company failed a number of times on his route to success. His first venture to build a motor car got dissolved a year and a half after it was started because the stockholders lost confidence in Henry Ford. Ford was able to gather enough capital to start again but a year later pressure from the financiers forced him out of the company again. Despite the fact that the entire motor industry had lost faith in him he managed to find another investor to start the Ford Motor Company - and the rest is history.
Walt Disney - one of the greatest business leaders who created the global Disney empire of film studios, theme parks and consumer products didn't start off successful. Before the great success came a number of failures. Believe it or not, Walt was fired from an early job at the Kansas City Star Newspaper because he was not creative enough! In 1922 he started his first company called Laugh-O-Gram. The Kansas based business would produce cartoons and short advertising films. In 1923, the business went bankrupt. Walt didn't give up, he packed up, went to Hollywood and started The Walt Disney Company.
Richard Branson - He is undoubtedly a successful entrepreneur with many successful ventures to his name including Virgin Atlantic, Virgin Music and Virgin Active. However, when he was 16 he dropped out of school to start a student magazine that didn't do as well as he hoped. He then set up a mail-order record business which did so well that he opened his own record shop called Virgin. Along the way to success came many other failed ventures including Virgin Cola, Virgin Vodka, Virgin Clothes, Virgin Vie, Virgin cards, etc.
Oprah Winfrey - who ranks No 1 in the Forbes celebrity list and is recognized as the queen of entertainment based on an amazing career as iconic talk show host, media proprietor, actress and producer. In her earlier career she had numerous set-backs, which included getting fired from her job as a reporter because she was 'unfit for television', getting fired as co-anchor for the 6 O'clock weekday news on WJZ-TV and being demoted to morning TV.
J.K. Rowling - who wrote the Harry Potter books selling over 400 million copies and making it one of the most successful and lucrative book and film series ever. However, like so many writers she received endless rejections from publishers. Many rejected her manuscript outright for reasons like 'it was far too long for a children's book' or because 'children books never make any money'. J.K. Rowling's story is even more inspiring because when she started she was a divorced single mum on welfare.
Bill Gates -co-founder and chairman of Microsoft set up a business called Traf-O-Data. The partnership between him, Paul Allen and Paul Gilbert was based on a good idea (to read data from roadway traffic counters and create automated reports on traffic flows) but a flawed business model that left the company with few customers. The company ran up losses between 1974 and 1980 before it was closed. However, Bill Gates and Paul Allen took what they learned and avoided those mistakes when they created the Microsoft empire.

There are lots of more example.

Friday, September 26, 2014

ASP.Net MVC Training Table Of Contents

Please get the installation completed of the following tools on your machine
  • Visual Studio 2012 or 2013
  • SQL Server 2012 (for developing database driven applications)

Following are the contents of training we will cover
  • 1       .NET Framework Overview
       We will read a book and will have a training session over Microsoft .NET Framework Application Development Foundation which covered most of the .Net Framework concepts as follow
o   .NET, CLR, MSIL/JIT, Assemblies, CTS, .NET languages            
o   Data Types, Operators, Expressions, Statements, Console I/O, if / switch / case, Loops, Arrays, Methods
o   Creating and Using Objects, Exceptions, Strings, Generics, Collections, Attributes
o   OOP Concepts such as Defining Classes, Constructors, Properties, Events, Interfaces, Inheritance, Polymorphism
  • 2      Introduction to ASP.Net MVC
The MVC Pattern
o   Model, View, Controller
o   The MVC Pattern for Web and Examples
ASP.NET MVC
o   Comparison with ASP.NET Form
o   ASP.NET MVC Advantages
Creating ASP.NET MVC Project
  • 3       Introduction to ASP.Net MVC Advance Topics
ASP.NET MVC Bundling
o   JQuery and JavaScript
ASP.NET MVC Routing
o   Route constraints
Controllers and Actions
o   Action results and filters
Razor Views
o   Layout and sections
o   Helpers
o   Partial views
Areas

Firstly, we are going to start .Net Framework Fundamentals which will cover most of the basic concepts of .Net framework and then we will start over ASP.Net MVC (Pro ASP.NET MVC 4).

Building Applications with ASP.Net MVC 4:

Prevent SQL Server Reporting Services Slow Startup


Problem: 

I've installed a SQL Reporting server 2012, with some reports. But I've some performances issues. 

The first call of the day to the server(report is access in MVC application), is VERY slow(something like 20-35 seconds at best), The report generation is then fast(1-2 seconds). I've the impression that it loads alll supporting dlls in the memory on first call the use cached dlls for rest of calls. But what can takes 20-35 seconds to be loaded in memory? And how to load it only once? 

These reports will be launched along with web application and will be accessed frequently, so they will always be slow on first load if I can't change this. And since it's available for customer, I just can't make them understand this(and the report is called through a website, so I risk to have timeout).

Solution:

I have solved the problem by Using the following articles as guidance:
  • Technet – “RSReportServer Configuration File” – http://technet.microsoft.com/en-us/library/ms157273.aspx
  • MSSQL Tips – “Prevent SQL Server Reporting Services Slow Startup” –http://www.mssqltips.com/sqlservertip/2735/prevent-sql-server-reporting-services-slow-startup/

I Scheduled a SQL Server job that will handle a report call periodically (for example every morning before everyone rushes to the office like I schedule it for 6:00 AM), for this I have written a powershell script which will warm up MS reporting server.

# URL to your SSRS. As example localhost is used.
[string] $url = "http://localhost/ReportServer";
$httpRequest = [System.Net.HttpWebRequest]::Create($url) ;
$httpRequest.Credentials =[System.Net.CredentialCache]::DefaultCredentials;
$httpRequest.Method = "GET";
# Time out has been set to 5 minutes to make sure the call is properly completed
$httpRequest.Timeout = 300000;
$objResponseReader = [System.IO.StreamReader]($httpRequest.GetResponse().GetResponseStream());
$objResponseReader.Dispose();

I Scheduled this job for daily at 6:00 in the morning.

Popular Posts