Skip to content

Instantly share code, notes, and snippets.

View ShamaUgale's full-sized avatar

Shama Ugale ShamaUgale

View GitHub Profile
@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) {
@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");
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");
@ShamaUgale
ShamaUgale / pom.xml
Created September 17, 2020 22:59
This is a sample pom.xml file for selenium 4
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>selenium4</groupId>
<artifactId>selenium4</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
@ShamaUgale
ShamaUgale / build.gradle
Created September 22, 2020 11:01
A sample build.gradle for downloading selenium 4 dependencies with gradle
plugins {
id 'java'
}
group 'SeleniumGradleSample'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {