Read/Write .xls and .xlsx with one set of code using POI - WorkbookFactory
we have to use:
For handling .xls files, we use HSSF (Horrible SpreadSheet Format) related POI classes.
For handling .xlsx files, we use XSSF (XML SpreadSheet Format) related POI classes.
On this post, how we can perform excel operations with one set code for both excel formats .xls and .xlsx.
For this we have a class provided from Apache POI WorkbookFactory, which auto detects appropriate kind of Workbook (HSSFWorkbook or XSSFWorkbook) depending on the excel formats .xls or .xlsx.
Let's jump to the code implementation
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Internet Explorer IE11 - F12 (debugging) not working
here is the fix:
Download and install the below respective patch, restart and click on F12 to get the html content.
For 32bit system:
https://www.microsoft.com/en-us/download/confirmation.aspx?id=45134
For 64bit system:
https://www.microsoft.com/en-us/download/confirmation.aspx?id=45154
Hope this helps!
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Download files in Chrome browser using selenium WebDriver
Find below code to download files in Chrome browser:
public class DownloadXL {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","./chromedriver.exe");
String downloadFilepath = "c:/download";
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("--test-type");
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, chromeOptionsMap);
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(cap);
driver.get("http://www.seleniumhq.org/download/");
driver.findElement(By.linkText("32 bit Windows IE")).click();
}
}
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Execute JavaScript in selenium to perform operations on HTML elements
Now let's see how we can perform actions on different web elements like
textbox - how we can enter text
Button - click
How to get attribute of a html element...
For input buttons
//js.executeScript("return document.getElementsByName('commit')[0].click();")
//or
//element = (WebElement) js.executeScript("return document.getElementsByName('commit')[0];");
//((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
//or
//element.click();
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Execute javaScript (locators) in selenium to identify HTML element
JavaScript has it's own locators to identify web elements:
getElementById - Returns single element that matches the ID.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Play with scroll bars on a page in selenium and javaScript
Selenium do not have it's own methods to perform this action, so we can use javascript to play on scroll lbars.
Let's see some of the ways:
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
All about JavaScriptExecutor in Selenium
Sometimes we observe web controls doesn't react well to selenium commands, there we can directly use / execute javascript commands using webdriver,
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
ways to drag n drop elements using selenium
Some examples:
Can customize menu bar items by drag child elements on parent element.
Drag and drop files/folders in some hierarchy manner.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
JSON : basic introduction and references
JavaScript Object Notation
Used as a lightweight data sharing format in between server and web application, and also in between web applications.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
which one to use? driver.close() / .quit()
Depending on scenarios, if single or multiple browsers are opened, we can close or quit browser.
let's see the usage of close, quit and dispose methods.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Agile development : manifesto
A group of developers together made a decission depending on their individual views and created the methodology called Agile.
In each development life cycle, it's the learning from the previous iteration and implement to improve the process...
There are 4 major compact principles (we call manifesto) to develop software/product in a better way, which talks as:
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Selenium v2.47.0 - features added
Selenium framework leaunched it's updated version 2.47.0Download link:
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Selenium with Autoit (no installation) for win UIs
There are situations in selenium automation, we get window dialog or we can say non browser related dialog which can not be automated with selenium. e.g Upload a file, download a file etc..
We will see how we can integrate Autoit with Selenium without installing Autoit.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Selenium HTML result reporting using ExtentReports 2.X
While browsing different ways of reporting, got web links of ExtentReports, most of the links talk about the version 1.x,
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Connect to DataBase in Java and Selenium Implementation
refer MySQL Basics
To automate database testing, we will use selenium with java language.
JDBC (Java DataBase Connectivity) is an API (using Java language) to connect and play with database with SQL queries.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
DataBase testing
Let's take an example of a e-commerce application,
user booked a mobile phone by entering phone model, shipping / billing address, and submits, Data stored into database.
Here we need to validate what the user enters data, should save exactly same to the database, then only correct device can be shipped to user.
In real time automation on database testing, user takes test data from external sources (excel or text file), enters detail on web application (then, data stores into database), then compares the external test data with the stored database data.....
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Initial setup of MySQL database and it's basic
For more information regarding versions and features, please refer http://dev.mysql.com/
Topics
- Download and Install.
- Initial Setup
- Creating database tables
- Adding/updating/deleting data to tables
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Firefox profile and preferences in selenium
Firefox profile contains information like your homepage, bookmarks, browser settings, history, saved passwords.
Profile is basically a specific folder stored locally in your hard drive other than your firefox installation folder.
We will see how we can set Firefox profile manually and then call in code or directly we can set the Firefox profile in code itself.
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
Selenium - ways to handle dropdown menus
Each item in the menu bar is a link corresponds to another page.
Menu bar have root items and in each root items we have one or more sub menus/items.
Actions on Root elements of a menu bar can be done as normal links, but sub elements are ( are hidden) only visible if we mouse hover to their corresponding root element,
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!
selenium implicit + Explicit + fluent waits
Loading depends on different criteria like internet bandwidth, technology used in the application, server capacity, no of users accessing the browser app etc...
While executing tests in different machines/environments, we need to make sure our script or code should wait till the elements load/present on the web page to perform some action upon them...
Selenium provides different ways to wait for an element on web page...
let's see them one by one -
This article is based on my learning or working experience, please leave comments if anything needs to be added or updated, Thanks!













