Skip to content

Instantly share code, notes, and snippets.

View ShamaUgale's full-sized avatar

Shama Ugale ShamaUgale

View GitHub Profile
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.WindowType;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
/*
This is an example to demonstarte the usage of newWindow() method in Selenium 4
New window or tabbed windows can be created and used in the single session and switch between them with
switchTo().window() method
@ShamaUgale
ShamaUgale / ActionsExample.java
Last active September 10, 2020 22:01
This is an example to demonstarte the difference bewteen Actions class methods usages in selenium 3 and 4
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class DeprecatedExamples {
final static String PROJECT_PATH = System.getProperty("user.dir");
@ShamaUgale
ShamaUgale / WaitExample.java
Created September 8, 2020 10:59
This is a demonstration of applying FluentWait in selenium 4 vs 3.
import java.util.concurrent.TimeUnit; // Selenium 3
import java.time.Duration; // Selenium 4
// selenium 3 usage
FluentWait wait = new FluentWait(driver)
.pollingEvery(20, TimeUnit.MILLISECONDS)
.withTimeout(20, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
//selenium 4 usage
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class ChromeDriverExample {
final static String PROJECT_PATH = System.getProperty("user.dir");
public static void main(String[] args) throws IOException {
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class EdgeDriverExample {
final static String PROJECT_PATH = System.getProperty("user.dir");
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.edge.driver", PROJECT_PATH+ "/src/main/resources/EdgeDriver.exe");
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.safari.SafariOptions;
public class SafariDriverExample {
public static void main(String[] args) throws IOException {
SafariOptions safariOptions = new SafariOptions();
safariOptions.setAcceptInsecureCerts(true);
@ShamaUgale
ShamaUgale / InternetExplorerDriverExample.java
Created September 8, 2020 17:07
Selenium 4 example working with driver capabilities
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
public class InternetExplorerDriverExample {
final static String PROJECT_PATH = System.getProperty("user.dir");
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.ie.driver", PROJECT_PATH+ "/src/main/resources/IEDriverServer.exe");
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.List;
public class FindsByExample {
final static String PROJECT_PATH = System.getProperty("user.dir");
public static void main(String[] args) {
package Tests;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
class GoogleSearchTest{
final static String PROJECT_PATH = System.getProperty("user.dir");