Thursday, 16 October 2014

How to Dismiss angular modal on URL change ?

Requirement :-
We have a Angular bootstrap Modal to show a popup window. On clicking backspace / browser back button, we want to cancel the popup and continue with the url change. The default behaviour is that page behind the modal changes, but the modal remains on top.
Plunker link for issue 
GitHub issue

Solution :- 

We have seen lot of people facing this challenging scenario . To overcome this issue is to write a directive in Angular JS.


app.directive('discardModal', ['$rootScope', '$modalStack',
    function($rootScope, $modalStack) {
        return {
            restrict: 'A',
            link: function() {
                * If you are using ui-router, use $stateChangeStart method otherwise use $locationChangeStart
                 * StateChangeStart will trigger as soon as the user clicks browser back button or keyboard backspace and modal will be removed from modal stack
                $rootScope.$on('$stateChangeStart', function (event) {
                    var top = $modalStack.getTop();
                    if (top) {

How to write my first Test Case using Selenium in Eclipse?

We are already finished with the prerequisite for starting with "Selenium".Now we are taking a step further towards learning "Selenium".
You can also check how to write first program in Eclipse.

Requirement:-Configuring Selenium Webdriver Jar files in Eclipse to write our first Selenium Program.

Step1:-Adding Jar files to Eclipse

Right Click "Java Project" in Package Explorer ->Build Path ->Configure Build Path

Opening add JAR dialog
Configure Build Path
Select Libraries Tab ->Click Add External JAR's

Window to Add JAR files
Add External JAR's
Browse to Selenium JAR files (For DownloadProcess) ->Add the Selenium JAR (We can add source JAR also) , Open the Lib folder to add all the JAR files.
Selenium JAR selection
Browse the Selenium JAR location
Click OK button to Add all the selected JAR files
Add JAR from Libraries
Adding JAR to Project

Note :- One's JAR files are added, we cna confirm under Reference in Project Explorer

Step2:- Writing and Running the first line of Selenium Code.(For running the First Java Program)

Flow :- Launching the firefox browser -> open the URL -> fetch the Title details.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class LearnSelenium {

public static void main(String[] args) {
  //Creating WebDriver Object
  System.out.println("Launching the Browser");
  WebDriver driver = new FirefoxDriver();
  //Opens the given URL
    System.out.println("Fetching the Title");
    System.out.println("Please Wait!!");
  //Returns the Title of Current Page
    String sTitle = driver.getTitle();
    System.out.println("My First Selenium Program");
    System.out.println("Title is = '"+sTitle+"'" );
   //Closing the Browser


Add the above lines of code and Run it to success (CTRL + F11)

Result in Console 
Console in eclipse
Console Results

Monday, 13 October 2014

"Hello World!"- My First Java Program in Eclipse.

Understanding IDE of Eclipse is the core for starting with Selenium. Today we are trying our age long program "Hello World!" in Eclipse using Java.Hope it would motivate our automation lovers in the journey towards Java and Selenium using Eclipse :)

Requirement:- How to write a Java program in Eclipse?

After downloading Eclipse, launch the IDE and select the WorkSpace.
Launching Eclipse

File ->New->JavaProject
Click Finish
JavaProject Dialog
Creating Java Project
Program will be created,under Package Explorer(On the Top Left Corner)
Note:-Incase "Package Explorer" is not visible, follow the path, Window->ShowView->Package Explorer
Launch Package Explorer
Package Explorer 
Right Click the "Java Project " in Package Explorer ->New ->Class

Give the Name of "Class" and click Finish
Note:- Select the option "public static void main(String[] args)" incase you want default method to be included in the code
Adding Class in Eclipse
Adding Class with default Method
Type "sysout" -> Press "CTRL+SpaceBar" -> Select the sysout option.
SysOut in Eclipse
SYSOUT shortcut
Write most awaited "HelloWorld!" inside the System.out.println(); and "File->Save"

RightClick the ProgramName ->RunAs->JavaApplication
Directly click the "Run" icon on the ToolBar(CTRL+F11)
Run Java Project in Eclipse
Run Java Program 

On the bottom, check the results under "Console"
Result in Eclipse
Console Result
Congrats!!We are done with our First Program :)

Sunday, 12 October 2014

How to solve the issue with Resize of TextArea in IE using JQUERY?

Requirement:- We need our TextArea should be flexible to be re-sized by user in Internet Explorer?

We followed the approach of JQuery to solve the problem.


Working Demo


css for TextArea
CSS part
HTML for TextArea
JavaScript for TextArea

Resize the TextArea
-We can apply the above code on other HTML elements also like DIV.
-We can also write the Directive in Angular to achieve the above results.

Prerequisites for starting with selenium?

Whole automation fraternity is crazy about the emerging demand of selenium.Today we are sharing our 1st post on selenium.We are not doing something out-of-box, however we tend to start a basic step towards helping people learn Selenium.Hope our this initiative can guide and mentor our budding automation coders.

Requirement:- What is required to execute and get acquaintance with Selenium.

Solution:- Java,Eclipse,FireBug&Selenium

Java :-
JDK(Java development Kit) is the first essential component to start with selenium.

After downloading, run the exe file to complete the installation


Java Download
Click on Download Link

Java download for Selenium
Select the appropriate options
 Note:- Installation is successful, we can verify that by typing "java" in command prompt
Cmd prompt for Java
Java is installed 
IDE(integrated development environment) for doing coding.

After downloading , extract the file and run the "eclipse.exe" to launch it.

Eclipse download
Select version of Eclipse

Download Eclipse
In the workspace, select the location where our code will be saved.
Select Path to save the code
It is a web development tool that facilitates the debugging, editing, and monitoring of any website's CSS, HTML, DOM, XHR, and JavaScript.We need this to work with webdriver, to get the location of elements like xpath or ID.

Download Firebug
Download Firebug
Note:- Try to download the latest available version.
After Installing, we can launch the plugin by navigating to "Web Developer" >> "Firebug".

Selenium WebDriver:-

After downloading and extracting the files,we will get a folder which should contain two jar files related to selenium, a lib folder which also contains jar files inside it. Beside this, there is a change log file as well.
Selenium Download
Downloading Selenium

Selenium Jar
Selenium Jar files