Posts

Showing posts from 2019

Fillo Excel API - Excel Read Write

Image
FILLO API Fillo is an Excel API for Java. Using Fillo API, we can consider excel sheet as data base and fetch data from excel [ .xls OR .xlsx ] by passing SQL query. Using Fillo API, we can insert new data and update existing data in Excel File. Fillo API supports below queries SELECT SELECT WITH WHERE CONDITION SELECT WITH LIKE OPERATOR INSERT UPDATE DELETE DOWNLOAD FILLO API https://codoid.com/fillo/ Fillo Libray can be downloaded from the above URL and configured in the JAVA project to start using it. If you are using MAVEN project then you can add below dependency in the pom.xml file and start using it. 1 2 3 4 5 <dependency>    <groupId> com.codoid.products </groupId>    <artifactId> fillo </artifactId>    <version> 1.21 </version> </dependency> Package Structure : pom.xml : ...

How to handle calendar or date picker using dynamic XPATH?

Image
Most of the times selecting a particular date from a date picker is a tedious job. We can easily automate this scenario with the help of dynamic XPATH. AUT : https://www.spicejet.com/ Test Steps : Navigate to  https://www.spicejet.com/ Enter Departure City Enter Arrival City Click on "Depart Date" date picker and select an appropriate date of departure Click on 'Flights' icon to view the available flights Test Script : package seleniumwebdriverbestpractices; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class HandleCalendarUsingDynamicXPATH { static WebDriver driver; public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub System.setProperty("webdriver....

How to do Page Scroll Using JavascriptExecutor?

package seleniumwebdriverbestpractices; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class ScrollPage { WebDriver driver; @Test public void scrollingPageTest() throws Throwable{ System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"\\drivers\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // driver.get("https://www.spicejet.com/"); driver.get("https://www.w3schools.com/"); driver.manage().window().maximize(); JavascriptExecutor js = (JavascriptExecutor)driver; // Scroll Down js.executeScript("window.scrollBy(0,1000)", ""); Thread.sleep...

How to handle calendar or date picker using JavascriptExecutor?

Image
Sometimes it is very difficult to select a particular date in Calendar or Date picker displayed in AUT (Application Under Test). It can be done easily by using JavascriptExecutor by setting the attribute value. Selenium doesn't have any inbuilt method to set attribute value or change anything in the HTML DOM (Document Object Model) structure. That's why we have to take the help of JavascriptExecutor to set the attribute value of a date picker. AUT :   https://www.spicejet.com/  [Spicejet website is taken as Application Under Test] Example : In the below image, we have a "DEPART DATE" calendar where a date [02-05-2019] needs to be selected. On inspecting the "DEPART DATE" web element, we will get the tag name and its attributes [Please see below Image] You can see the value of attribute " value " is " 31-05-2019 " During run time, we can change the attribute value by...

How to upload a file using AutoIT?

Image
Download AutoIT from  https://www.autoitscript.com/site/autoit/downloads/  as shown in the below image Download AutoIT  Script Editor from  https://www.autoitscript.com/site/autoit/downloads/  as shown in the below image Double click on the " autoit-v3-setup.exe " to install AutoIT. Double click on the " SciTE4AutoIt3.exe " to install AutoIT Script Editor. Once you are done with the installation, you can see Identifier or Finder tool in the below path C:\Program Files (x86)\AutoIt3\ Au3Info_x64.exe You need to double click on it to open Finder Tool Methods to be used ================== ControlFocus ( "title", "text", controlID ) : Sets input focus to a given control on a window. ControlSetText ( "title", "text", controlID, "new text" [, flag = 0] ) : Sets text of a control ControlClick ( "title...

How to send email notification from Jenkins with TestNG Report?

Image
1. If you don't how to configure Jenkins and run project then please            refer  http://seleniumbestpractices.blogspot.com/2018/08/how-to-run-selenium-project-from.html 2. start jenkins.war file to get started with Jenkins. 3. Go to http://localhost:8080 to open Jenkins. Required Plugins *********************** Email Extension Email Extension Template Plugin TestNG Results Selenium HTML Report Configuration for Sending Email ****************************************** Go to Jenkins => Manage Jenkins => Configure System => Email Notification Enter " smtp.gmail.com " in the " SMTP Sever " edit field  NOTE : we will take gmail as an example Click on " Advanced " and do the configuration as shown in the below image. Username and password need to be provided for the account from where you want to send the email notification. For testing purpose, check the " Test configuration by sending test e-mail ...

How to find broken links on a web page?

package selenium; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class LinkChecker { WebDriver driver; @BeforeClass public void setUp(){ System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"//drivers//chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(30,TimeUnit.SECONDS); driver.get("http://newtours.demoaut.com"); } @Test public void findBrokenLinks() throws IOException{ List<WebElement> allLinks = driver.fin...