Skip to content

Commit

Permalink
1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Umut Ay Bora committed Mar 30, 2023
1 parent d96fb44 commit 922af5c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 33 deletions.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.umutayb</groupId>
<artifactId>Pickleib</artifactId>
<version>1.6.9</version>
<version>1.7.0</version>
<packaging>jar</packaging>

<name>Pickleib</name>
Expand Down Expand Up @@ -109,6 +109,13 @@
<version>${okhttp.version}</version>
</dependency>

<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
</dependency>

<!-- Retrofit -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils.driver;
package pickleib.driver;

import com.github.webdriverextensions.WebComponent;
import org.apache.xerces.impl.dv.util.Base64;
Expand Down Expand Up @@ -34,12 +34,12 @@ public class Driver extends WebComponent {
static Printer log = new Printer(Driver.class);

/**
* Initializes a specified driver
* Initializes a specified type of driver
*
* @param driverType driver type
*/
public static void initialize(DriverFactory.DriverType driverType){
log.new Info("Initializing driver...");
log.new Info("Initializing pickleib.driver...");
driver = DriverFactory.getDriver(driverType);
wait = new WebDriverWait(driver, Duration.of(DriverFactory.driverTimeout, ChronoUnit.SECONDS));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils.driver;
package pickleib.driver;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.junit.Assert;
Expand Down Expand Up @@ -77,33 +77,33 @@ public class DriverFactory {
static PageLoadStrategy loadStrategy;

/**
* determines usage of web driver manager
* determines usage of web pickleib.driver manager
*/
static Boolean useWDM;

/**
* determines usage of web driver manager
* determines usage of web pickleib.driver manager
*/
static Boolean allowRemoteOrigin;

/**
* Initializes and returns a driver of specified type
* @param driverType driver type
* @return returns driver
* Initializes and returns a pickleib.driver of specified type
* @param driverType pickleib.driver type
* @return returns pickleib.driver
*/
public static RemoteWebDriver getDriver(DriverType driverType){
useSeleniumGrid = Boolean.parseBoolean(properties.getProperty("selenium-grid", "false"));
frameWidth = Integer.parseInt(properties.getProperty("frame-width","1920"));
frameHeight = Integer.parseInt(properties.getProperty("frame-height","1080"));
driverTimeout = Long.parseLong(properties.getProperty("driver-timeout", "15000"))/1000;
driverTimeout = Long.parseLong(properties.getProperty("pickleib.driver-timeout", "15000"))/1000;
headless = Boolean.parseBoolean(properties.getProperty("headless", "false"));
deleteCookies = Boolean.parseBoolean(properties.getProperty("delete-cookies", "false"));
maximise = Boolean.parseBoolean(properties.getProperty("driver-maximize", "false"));
maximise = Boolean.parseBoolean(properties.getProperty("pickleib.driver-maximize", "false"));
insecureLocalHost = Boolean.parseBoolean(properties.getProperty("insecure-localhost", "false"));
loadStrategy = PageLoadStrategy.fromString(properties.getProperty("load-strategy", "normal"));
disableNotifications = Boolean.parseBoolean(properties.getProperty("disable-notifications", "true"));
allowRemoteOrigin = Boolean.parseBoolean(properties.getProperty("allow-remote-origin", "true"));
useWDM = Boolean.parseBoolean(properties.getProperty("web-driver-manager", "false"));
useWDM = Boolean.parseBoolean(properties.getProperty("web-pickleib.driver-manager", "false"));

RemoteWebDriver driver;

Expand Down Expand Up @@ -132,20 +132,20 @@ public static RemoteWebDriver getDriver(DriverType driverType){
throw new RuntimeException(gamma);
}
else
{throw new RuntimeException(YELLOW+"Something went wrong while selecting a driver "+"\n\t"+RED+gamma+RESET);}
{throw new RuntimeException(YELLOW+"Something went wrong while selecting a pickleib.driver "+"\n\t"+RED+gamma+RESET);}
}
}

/**
* Selects the driver type and assigns desired capabilities
* Selects the pickleib.driver type and assigns desired capabilities
*
* @param headless session runs headless if true
* @param useWDM WebDriverManager is used if true
* @param insecureLocalHost enables insecure local host if true
* @param disableNotifications disables browser notifications if true
* @param loadStrategy determines page load strategy
* @param driverType driver type
* @return returns the configured driver
* @param driverType pickleib.driver type
* @return returns the configured pickleib.driver
*/
static RemoteWebDriver driverSwitch(
Boolean headless,
Expand Down Expand Up @@ -192,7 +192,7 @@ static RemoteWebDriver driverSwitch(
return new SafariDriver(safariOptions);
}
default -> {
Assert.fail("No such driver was defined.");
Assert.fail("No such pickleib.driver was defined.");
return null;
}
}
Expand All @@ -205,7 +205,7 @@ static RemoteWebDriver driverSwitch(
}

/**
* available driver types
* available pickleib.driver types
*/
public enum DriverType {
CHROME("Chrome"),
Expand All @@ -227,9 +227,9 @@ public String getDriverKey() {
}

/**
* Returns driver type matching a given text (Non-case-sensitive)
* @param text desired driver
* @return returns matching driver type
* Returns pickleib.driver type matching a given text (Non-case-sensitive)
* @param text desired pickleib.driver
* @return returns matching pickleib.driver type
*/
public static DriverType fromString(String text) {
if (text != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package exceptions;
package pickleib.exceptions;

public class PickleibException extends RuntimeException {
public PickleibException(String errorMessage) {super(errorMessage);}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package steps;
package pickleib.steps;

import com.github.webdriverextensions.WebComponent;
import context.ContextStore;
Expand All @@ -8,8 +8,8 @@
import org.openqa.selenium.remote.RemoteExecuteMethod;
import org.openqa.selenium.remote.html5.RemoteWebStorage;
import org.openqa.selenium.support.ui.ExpectedConditions;
import utils.ScreenCaptureUtility;
import utils.WebUtilities;
import pickleib.utilities.ScreenCaptureUtility;
import pickleib.utilities.WebUtilities;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package utils;
package pickleib.utilities;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.remote.RemoteWebDriver;
import utils.NumericUtilities;
import utils.Printer;

import java.io.File;

import static utils.StringUtilities.Color.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils;
package pickleib.utilities;

import com.github.webdriverextensions.WebComponent;
import com.github.webdriverextensions.WebDriverExtensionFieldDecorator;
Expand All @@ -17,11 +17,11 @@
import org.openqa.selenium.*;
import java.util.*;
import context.ContextStore;
import utils.driver.Driver;
import java.time.Duration;
import org.junit.Assert;
import exceptions.PickleibException;

import pickleib.driver.Driver;
import pickleib.exceptions.PickleibException;
import utils.*;
import static utils.StringUtilities.Color.*;

@SuppressWarnings({"unused", "UnusedReturnValue"})
Expand Down Expand Up @@ -945,7 +945,7 @@ public String switchWindowByHandle(@Nullable String handle){
log.new Info("Switching to the next tab");
String parentWindowHandle = driver.getWindowHandle();
if (handle == null)
for (String windowHandle:driver.getWindowHandles()) {
for (String windowHandle: driver.getWindowHandles()) {
if (!windowHandle.equalsIgnoreCase(parentWindowHandle))
driver = (RemoteWebDriver) driver.switchTo().window((windowHandle));
}
Expand Down Expand Up @@ -1081,7 +1081,8 @@ public void dragDropAction(WebElement element, int xOffset, int yOffset){
* Refreshes the current page
*
*/
public void refreshThePage(){driver.navigate().refresh();}
public void refreshThePage(){
driver.navigate().refresh();}

/**
* Click coordinates specified by the given offsets from the center of a given element
Expand Down

0 comments on commit 922af5c

Please sign in to comment.