Search uftHelp.com:

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.

Code:-



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) {
                        $modalStack.dismiss(top.key);
                    }
                });
            }
        };
    }
 ]);



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.

Solution:-
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
    driver.get("http://www.uftHelp.com");
    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
    driver.close();
 }

}

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?

Solution:-
Step1:-
After downloading Eclipse, launch the IDE and select the WorkSpace.
Eclipse
Launching Eclipse



Step2:-
File ->New->JavaProject
Click Finish
JavaProject Dialog
Creating Java Project
Step3:-
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 
Step4:-
File->New->Class
or 
Right Click the "Java Project " in Package Explorer ->New ->Class


Step5:-
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
Step6:-
Type "sysout" -> Press "CTRL+SpaceBar" -> Select the sysout option.
SysOut in Eclipse
SYSOUT shortcut
Step7:-
Write most awaited "HelloWorld!" inside the System.out.println(); and "File->Save"

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

 Step9:-
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?

Solution:-
We followed the approach of JQuery to solve the problem.

Method:-
Resizable 

Working Demo

Code:-


CSS:-
css for TextArea
CSS part
HTML:-
HTML for TextArea
HTML Code
JavaScript:-
JavaScript for TextArea
JavaScript
Result:-

TextArea
Resize the TextArea
Note:-
-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

Steps:-


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 
Eclipse:-
IDE(integrated development environment) for doing coding.


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

Steps:-
Eclipse download
Select version of Eclipse

Download Eclipse
In the workspace, select the location where our code will be saved.
WorkSpace
Select Path to save the code
Firebug:
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.


Steps:-
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