Posts

Cypress Cheat Sheet

Since you have landed on this blog post which means you already have started to know about Cypress and wanted have a quick glance of the Cypress commands. Cypress Commands /// <reference types="Cypress"/> add the above line to make use of intelli sense in cypress ide visual studio code editor cy.visit similary to driver.get() or navigate() in Selenium Webdriver. To launch a url in the browser. cy.get('csslocator') get is like findElement, identifies the element in the web page based on css provided. wait explicitly for an element: cy.get('#id1', {timeout: <timeinmilliseconds>}) when finding an element, adding additional parameter "timeout" makes cypress to wait for the specified time interval until the element is visible. cy.wait(time) similar to thread.sleep cy.type('learner') enters text in the textbox cy.get('#abc:visible') retrieves only visible elements cy.get('#abc').find('

Interacting with Existing chrome browser using Selenium Webdriver

The only pain when working with WebDriver is to re-run the whole test after the test failure. This can be handled writing wrapper to fetch the Remote Webdriver session url and session id of the launched browser. The working code mentioned in the blog post is tested in chrome browser. However the code developed can be extended to other browsers as well. The Java Class with working code is available in github  link .

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 and a feature file. import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(strict=true) public class Cucumberru

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.currentTimeMillis();

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