Skip to content

Instantly share code, notes, and snippets.

View pragmatictesters's full-sized avatar
😀
Learn | Train | Transform | Earn

Janesh Kodikara pragmatictesters

😀
Learn | Train | Transform | Earn
View GitHub Profile
@pragmatictesters
pragmatictesters / ActionsClassExample.java
Created January 4, 2019 09:33
Selenium WebDriver Examples : Demonstrate use of Actions class to simulate user gestures
package com.pragmatic.selenium.examples;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
@pragmatictesters
pragmatictesters / CrossBrowserTest.java
Last active January 30, 2019 03:53
Selenium WebDriver Examples : Demonstrates using various browser for the testing. All major browsers, headless browsers and Mobile Emulations are included
package com.pragmatic.selenium;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
@pragmatictesters
pragmatictesters / MoveToElementExample.java
Created December 31, 2018 19:43
Selenium WebDriver Examples : Move , Scroll to an element using Actions class and JavascriptExecutor
package com.pragmatic.selenium.examples;
import io.github.bonigarcia.wdm.WebDriverManager;
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.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterMethod;
@pragmatictesters
pragmatictesters / ReadDataFromCSV.java
Created December 31, 2018 19:11
Selenium WebDriver Examples : Reading test data from a CSV file and use them in a test method
package com.pragmatic.selenium.examples;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.*;
@pragmatictesters
pragmatictesters / AddEmployeeTest.java
Created December 29, 2018 14:44
Selenium WebDriver Examples : Working with basic web elements
package com.pragmatic.selenium.hrm;
import com.github.javafaker.Faker;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
@pragmatictesters
pragmatictesters / ReadDataFromXL.java
Created December 29, 2018 09:11
Selenium WebDriver Example : Data Drivern Testing. Demonstrate reading data from XL file
package com.pragmatic.selenium.examples;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
@pragmatictesters
pragmatictesters / SwichWindowExample.java
Created December 29, 2018 06:40
Selenium WebDriver Examples : Switching between browser windows
package com.pragmatic.selenium.examples;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@pragmatictesters
pragmatictesters / TestBase.java
Created December 28, 2018 17:36
Selenium WebDriver Examples : Sample TestBase class with support for cross browser testing with headless capabilities
package com.pragmatic.selenium.hrm;
import com.github.javafaker.Faker;
import com.pragmatic.selenium.hrm.pages.LoginPage;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
@pragmatictesters
pragmatictesters / 1user-login.feature
Last active December 29, 2018 06:32
Selenium WebDriver Cucumber Integration Example : Sample Feature File and Step Definition file
Feature: User login feature
Sample Feature File with Data Driven Testing (DDT)
Scenario: Invalid user login with blank password
Given I have accessed the HRM login page
When I type username "Admin"
And I type password ""
And I click login button
Then I should see error message "Password cannot be empty"
@pragmatictesters
pragmatictesters / TakeScreenshotExample.java
Last active December 28, 2018 17:43
Selenium WebDrive Examples - Take a Screenshot with a time stam
package com.pragmatic.selenium.hrm.examples;
import com.github.javafaker.Faker;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;