Like us on Facebook

LightBlog

October 30, 2015

Run selenium tests in Chrome and IE browser

October 30, 2015 29
How to run the selenium test scripts in Chrome/IE browser ?

To run the selenium test cases in Chrome/IE browser is necessary and need of today's web world as Chrome being the one of the best and most widely used web browser.

Selenium by default supports only Mozilla Firefox . 

To run your tests in Chrome browser please do the following set-up.

1. Download chrome browser related jar file from here.

2. Set the System configuration by adding the following code.

System.setProperty("webdriver.chrome.driver", "Path to chrome related jar file downloaded in step 1");
WebDriver driver = new ChromeDriver();

To run the test in Internet explorer.

1. Download IE browser related jar file from here.

2. Set the System configuration by adding the following code.

System.setProperty("webdriver.ie.driver", "C:\\Users\\ajain5\\Downloads\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();



October 20, 2015

Handling Basic Authentication Using Webdriver

October 20, 2015 32
Here is post which explains you how to handle basic authentication.

Problem:

Some of the applications that are secured with Basic Authentication. If you want to access those applications first you need to pass credentials. Those applications will launch a system level pop-up which cant not be handled by selenium.

IF you access below url it will ask for authentication.

http://the-internet.herokuapp.com/basic_auth



Solution:

By specifying userName and password in URL when accessing the page we can avoid system level dialog. This approach will work for HTTP and HTTPS pages.


Reference: http://elementalselenium.com/tips/13-work-with-basic-auth

Example:

October 8, 2015

Selenium Integration With Jenkins

October 08, 2015 15
In this post i am going to explain how to integrate with continuous integration tool Jenkins..

Prerequisites:
Here i am trying to run Maven project scripts so

  1. Maven Project with TestNG (you can go through this post  create-sample-maven-project.html)
  2. and few webdriver scripts
  3. Downlaod Maven Project from Here....
Download Jenkins:

1. Navigate ti http://jenkins-ci.org/
2. Download .war file

3. Save the jenkins.war file in any of the location, you need to run this Jenkins.war file.


Set Up Jenkins:

1. Navigate to folder where you kept your jenkis.war
2. type command java -jar jenkins.war and press Enter

3. Will take some time to extract Jenkins, then you will get a success message.
4. By default Jenkins will start in port number 8080
5. For Jenkins UI use this URL in browser http://localhost:8080/



Configure Jenkins:

Before creating any Jenkins job we need to perform some configuration steps.
1. Click on Manage Jenkins link on the left side of the page
2. Click on Configure System.
3. Navigate to JDK section and Click on Add JDK button
4. Uncheck Install automatically check box so Jenkins will only take java which we have mention above
5. Give the name as JAVA_HOME and Specify the JDK path


6. Add Maven. IF you already not downloaded maven, get it from here Download Maven


6. Click on Save button.


Create Jenkins Job:
1. Click on create new Jobs.
2. Enter Job description and select Maven Project
3. Go to Build section and Enter path of POM.xml in ROOT POM text box.
4. Click apply and Save,



Run Job:
Navigate to Home page of Jenkins, there you can see new Job is created. Click on Build now symbol

Maven will build the project. It will then have TestNG execute the test cases
Once the build process is completed, in Jenkins Dashboard click on the Job1 project






October 7, 2015

Log4J Configuration

October 07, 2015 19
In this post i will discuss about Log4J and Log files.

Log file is just simple file, which keep track of the record or event or info when any event happens or any software run. This whole process known as logging. We can create log file as simple log file.

Why Log file is required:

We can create log file for our simple script also so we can track or debug our script easily if anything goes wrong in script. For example, if our script is failing at some point then we can track back what went wrong

What is log4J
Log4j is free open source tool  for creating log files It help us to generate log file.

Log4j is very lightweight and simple logging framework, comprising of three main components
Loggers
Appenders
Layouts

Download Log4J jar file.

1. Navigate to http://mvnrepository.com/
2. Search for Log4J
3. Download latest version of log4J




Create a sample Java project and add log4J. jar file to project.

Create a properties file 
Right click on Project --New --File
give a name log4j.properties.
and add below code in that file






Create a Class file with below log levels:


logger.debug("Sample debug message");
logger.info("Sample info message");
logger.warn("Sample warn message");
logger.error("Sample error message");
logger.fatal("Sample fatal message");

Below is the sample code:



After executing test you can see logs in log4j.log file and in console as well.






OUTPUT of Log4J file:



October 2, 2015

Handling webtables

October 02, 2015 81
Handling webtables
This post explains about Handling Webtables.

Get Number of Columns
Get Number of Rows
Get Content of a specific cell based on Row and Column value.

Below is the code: