Category Archives: Software Testing

PROBESEVEN - Global Security Option in Jenkins

jenkins_blog poster

A watch out to the software professionals, you may not know about which am turned to discuss. Oh! Yes, I wish to quote that this option does not come in the default configuration, as Jenkins does not insist on any default security check. So, it directly means that the person working on it for the installation need to work on the global security option in Jenkins.
Okay, just as you proceed also check over this, may be you would wish to learn here how to integrate selenium with Jenkins!
Once after the completion of the installation you are advised to integrate the global security option, which works on 2 axes: the security realm using the log in credentials and the authorization strategy which gives you the option to access the permission settings. Cater to the below procedures to work on setting the global security for your projects in Jenkins and understanding the Global Security Option in Jenkins.
Step 1:
Configure Jenkins:
  • Open Command Prompt & follow the following steps to configure Jenkins
  • Go to the particular directory where Jenkins.war is installed & enter the following command java –jar Jenkins.war

Jenkins1

  • You will get Jenkins is fully up and running in Command Prompt if Jenkins configured correctly.

Jenkins2

  • Open browser go to the given URL – http://localhost:8080/
  • Normally Jenkins uses 8080 port to run.
  • Jenkins Dashboard will be displayed.
Step  2:
Configure Global Security Option:
  • Click on Manage Jenkins Button present in Jenkins dashboard & open Manage Jenkins Page.
  • Select Configure Global Security option present in Manage Jenkins Page.

Jenkins3

  • Select Enable Security Checkbox Present in Configure Global Security Page.
  • Click on Jenkins own user database Radio button from Security Realm section & then click on Matrix based security radio button present in Authorization section.

security_jenkins

 

Set Username/Group name:
  • Enter User/Group Name and click on Add Button.
  • For example I have entered Test User in Matrix based security section.
  • Select Permissions to the newly added user & then click on SAVE Button.

Jenkins5

Just get started:
  • Jenkins Login Page should be displayed.
  • Click on Create an Account Link to create new user.

Jenkins6

  • Enter Username as Test in Signup form & enter all valid details and then click on Signup Button.
  • Test User is successfully Logged in to Jenkins account.

Jenkins7

  • Click on Logout Link present at top of the Jenkins dashboard.
  • Jenkins Login Page should be displayed.
  • Whenever you are trying to open Jenkins (http://localhost:8080/) it will ask you for username & password to login.

Jenkins8

Success over it or get this:
  • If both Username & Password matches means Jenkins will display dashboard. Otherwise it throws an error message.

Jenkins9Global Security Option in Jenkins is Configured Successfully!

You can now protect your Jenkins data using Global Security option. Stay with peace of mind and make your projects highly secured.
Doubtless, wish to get your comments and let’s discuss more in the comments session. Drop me few words which I would be glad to reply. 

 

PROBESEVEN - Learn How to Integrate Selenium with Jenkins!

Selenium1mage

Here is a knowledge share of running test scripts via Jenkins. You would now have a brief guidelines and document demo of creating sample test scripts. We would be using Eclipse IDE/Net beans IDE and I have used Eclipse IDE and TestNG in this demo.
Creating Sample Test Script:
  • Use Eclipse IDE/ Net beans IDE.
  • In my demo I have used Eclipse IDE & TestNG.

SAMPLE CODE & ECLIPSE CONSOLE OUTPUT:

  • After creating sample script Right Click on the Project à Go To TestNG & click on Convert to TestNG button.
  • testng.xml file is created and stored in Eclipse workspace.

cele1Download Jenkins:

Now, you are required to open browser & go to the given URL – https://jenkins-ci.org/ and follow the steps below.

  • Click on the Latest and greatest (1.630) link as highlighted in below image
  • The latest version of Jenkins is 1.630
  • Jenkins.war file should be downloaded in your default download location.

cele2

Configure Jenkins:
  • Open Command Prompt & follow the following steps to configure Jenkins.
  • Go to the particular directory where Jenkins.war is installed & enter the following command java –jar Jenkins.war

cele3

You will get Jenkins is fully up and running in Command Prompt if Jenkins configured correctly.

cele4

Open Jenkins to view:
  •  Open browser go to the given URL – http://localhost:8080/
  • Normally Jenkins uses 8080 port to run.
  • Jenkins Dashboard will displayed with Welcome to Jenkins! Message

cele5

Integrating Selenium with Jenkins:

Step 1: Initially your Eclipse IDE workspace contains following items:

  • bin folder
  • src folder
  • test output folder
  • testng.xml file

Step 2: You need to add new directory called lib which contains all library jar files.

Step 3: Open Command Prompt & Go to the Jenkins Project workspace created by Eclipse IDE. Use the following command to set classpath.

cele6

Step 4: Create new Text Document. Open the newly created Text Document and enter following code into it.

java -cp bin;lib/* org.testng.TestNG testng.xml

Step 5: While saving the text document give file name within the double quotes as shown below.

cele7

Success! New run windows batch file is created.

Creating New Job in Jenkins:

cele8In order to create a new job in Jenkins you are required to click on create new jobs in Jenkins dashboard.

  • Enter item name as Jenkins Demo, Select Freestyle project radio button & click on OK button.
  • Click on the Advanced button Present in Advanced Project Options & Select Use Custom Workspace checkbox
  • Enter the directory path where eclipse project is saved(Eclipse IDE Workspace where src, bin, lib & testing.xml files are stored)
  • In Build section click on Add build step drop down & select Execute windows batch command.
  • Enter command as run.bat (windows batch file created in workspace)
  • Click on Apply & than Save button
 Project Jenkins Demo is successfully added.
  • Click on Build Now button. New build is successfully created & Build History updated the Build Report
  • Click on Build Report newly generated by Jenkins.
  • Jenkins Console Output is displayed as shown below.
cele9
Selenium is now successfully integrated with Jenkins.

PROBESEVEN - Selenium WebDriver – Automation Testing Tool

SELENIUM WEBDRIVER- A TEST STRATEGY

Selenium is a automation tool for Testing, which are collection of different tools for Automation Testing. Selenium is not just a single tool but a suite of software, each catering to different testing needs of an organization. It has four components.

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • Webdriver
  • Selenium Grid

Why Webdriver:

WebDriver is a tool for automating testing web applications, and in particular to verify that they work as expected. It aims to provide a friendly API that’s easy to explore and understand, which will help make your tests easier to read and maintain. It’s not tied to any particular test framework, so it can be used equally well with JUnit, TestNG or from a plain old “main” method.

This “Getting Started” guide introduces you to WebDriver’s Java API and helps get you started becoming familiar with it. Webdriver allows your test scripts to communicate directly to the browser, thereby controlling it from the OS level.

  • To open source
  • To use a certain programming language in designing your test case
  • To test applications that are rich in AJAX-based functionalities
  • To execute tests on the HtmlUnit browser
  • Create scripts in Multi language (Java, perl, c# and phyton)
  • Run the Script on different type of browser.

Web Driver uses a different underlying framework from Selenium’s java-script Selenium-Core. It also provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not depend on a JavaScript core embedded within the browser; therefore it is able to avoid some long-running Selenium limitations.The Selenium developers strive to continuously improve Selenium.

Integrating WebDriver is another step in that process. The developers of Selenium and of WebDriver felt they could make significant gains for the Open Source test automation community be combining forces and merging their ideas and technologies. Integrating WebDriver into Selenium is the current result of those efforts.

Advantages of Selenium Webdriver:

  • Improved features & functionality which were not supported in the Selenium 1.0
  • No need to start server prior to start executing scripts
  • Added advantage to support for iPhone and Android testing
  • It supports features like Page navigation, Drag-and-drop and AJAX-based UI elements
  • Using WebDriver can easily find the coordinates of any object
  • WebDriver is open source & it allows you to easily integrate with testing framework like JUnit or TestNG
  • It provides the improved reliability between browsers
  • For web application testing, it provides standard programming interface

Working Principles:

Picture1

Selenium 2.0 (Webdriver), the supported browsers vary depending on whether you are using Selenium-Webdriver scripts like Firefox, IE, Safari or Chrome.We can write the testing scripts and run in any browser and finding the result easily. If we writing a script for Fire fox browser, we can change the same script for IE or other browser with a little change like browser name. So we can create a single script and run it on different browser.

Scripts:

Here we can create a script and run it in different browser. In he bellow example scripts developed for Firefox.

package example;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class drive {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get(“http://www.probeseven.com/”);
String actualTitle = driver.getTilte();
String expectedTitle = “PROBESEVEN :: Online Branding Company”;
String actualTitle = “”;
if (actualTitle.contentEquals(expectedTitle))
{
System.out.println(“Test Passed!”);
}
else
{
System.out.println(“Test Failed”);
}
//close Firefox
driver.close();
// exit the program explicitly
System.exit(0);
}

Run in Different browser:

The last example script only run in Firefox browser. If we want to run the same script in Chrome or IE browser, just we make some little changes are enough in the script. For example, instead of Firefox driver, we can replace it by Chrome driver.

WebDriver driver = new ChromeDriver();

In case, we change it to Chrome Driver means, the same script run on Chrome driver and we can find the result too.

TestNG and JUnit:

TestNG and JUnit are the mostly used frameworks in selenium webdriver for reporting the bugs in document format like excel sheet. JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development. To execute Selenium WebDriver testing using JUnit we have to add JUnit annotations in your test. Using these two methods we can have the inputs from excel sheet and process the inputs and generate the output by selenium result to excel sheet.

Selenium IDE:

IDE is a excellent play and back tool with Firefox add-on. We can start the IDE add-on and continue our web application testing. Here each and every clicking and opened pages are stored by IDE and finally it produce the results.

The Selenium IDE is an excellent starting point to start using and learning Selenium. For a short description, the Selenium IDE is a plugin for the Firefox browser that let’s one click and record actions in the web browser. In addition, it adds options to your contextual menu (the right click menu) that helps you create tests.

As a result, you can very quickly create and prototype scripts for automation. The IDE should come up so we’re well on our way to creating our first automated script using the IDE. For our first script, let’s pretend we’re working at Google and we want to make sure that when someone searches for something, their query remains in the search field on the results page.  Before we get to creating our script, let’s familiarize ourselves with some of the basic functionality as well as the UI.