Posts

Cucumber--@CucumberOptions

There are lot of attributes that are available for @CucumberOptions. I will be sharing some of them in this blog post. Sample Feature file: Feature: Life of IT Tester Scenario Outline: I am a tester Given I am a "<TesterType>" tester When I go to work Then I "<Work_Output>" it And my boss "<Boss_Action>" me But the developer "<Developer_Reaction>" me Examples: |  TesterType  |  Work_Output | Boss_Action | Developer_Reaction | |   Good       |   Complete   |  Salutes    |   hates            | |   Bad        |   Mess       |  Fires      |   Likes            | |   avg        |   sufficient |  encourages |   respects         | 1. Strict: (true|false) Just develop the Runner class...

Selenium WebDriver with IE- Unable to Get browser Exception (workaround)

When you run your tests with Internet Explorer and have a restriction of not modifying the IE Settings as recommened as below. On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode". At some point of time, while switching between windows WebDriver throws "Unable to get browser" Exception.  After many probable methods of fixing the issue. Here is the solution that worked for me. //Initially setting the window id to null.  String window=null;    //Setting the maximum wait time for the browser window to open     long waittime=8000;  Long start=System.currentTimeMil...

Uploading Bulk data into MySql database using Java

Image
Let us see how can we upload / insert bulk data into MySql database from an excel So that we have data ready in excel . Let's see the java program to connect and upload data. We'll split our requirement into following sub tasks: 1. Connection to My Sql database. 2. Read the Excel using Apache POI. 3. Insert the data,by iterating row by row in the excel. 4.Close the database connection. Here's how it is implemented: package sample; import java.io.FileInputStream; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; import java.util.Iterator; import org.apache.poi.ss.formula.functions.Column; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public cl...

To Find out whether a number is Armstrong number

  Armstrong number  is a number that is the sum of its own digits each raised to the power of the number of digits. Let us Look at how to find out whether the number is Armstrong using java. Note: The input is saved in Text file. Input: 7 181 153 Output: True False True import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.File; public class Armstrong {     public static void main (String[] args)  throws FileNotFoundException,NumberFormatException{          File file = new File(args[0]);     BufferedReader in = new BufferedReader(new FileReader(file));    int len;    String currentline;                               ...