Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(java): ✨ added browser version feature #794

Merged
merged 7 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body:
attributes:
label: Issue Version
description: 🔢 What version of the framework is this bug related to?
placeholder: v0.22.1
placeholder: v1.0.0
validations:
required: true

Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<a href="https://github.com/BoykaFramework/boyka-framework/commits/main">
<img src="https://img.shields.io/github/last-commit/BoykaFramework/boyka-framework?style=for-the-badge" alt="last update" />
</a>
<a href="https://mvnrepository.com/artifact/io.github.boykaframework/boyka-framework">
<a href="https://central.sonatype.com/artifact/io.github.boykaframework/boyka-framework">
<img src="https://img.shields.io/maven-central/v/io.github.boykaframework/boyka-framework.svg?style=for-the-badge" alt="Maven Central" />
</a>
<a href="https://github.com/BoykaFramework/boyka-framework/releases/tag/v0.22.1">
<img src="https://img.shields.io/github/downloads/BoykaFramework/boyka-framework/v0.22.1/total?color=brightgreen&label=Downloads%20for%20v0.22.1&logo=GitHub&style=for-the-badge" alt="GitHub releases" />
<a href="https://github.com/BoykaFramework/boyka-framework/releases/tag/v1.0.0">
<img src="https://img.shields.io/github/downloads/BoykaFramework/boyka-framework/v1.0.0/total?color=brightgreen&label=Downloads%20for%20v1.0.0&logo=GitHub&style=for-the-badge" alt="GitHub releases" />
</a>
<a href="https://github.com/BoykaFramework/boyka-framework/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/BoykaFramework/boyka-framework.svg?style=for-the-badge" alt="license" />
Expand Down Expand Up @@ -90,7 +90,7 @@ Use this space to tell a little more about your project and how it can be used.
<dependency>
<groupId>io.github.boykaframework</groupId>
<artifactId>boyka-framework</artifactId>
<version>0.22.1</version>
<version>1.0.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion core-java/checkstyles/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</module>
<!-- Validate whitespace around Generics (angle brackets) per typical conventions
http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace -->
<module name="GenericWhitespace"/>
<!-- <module name="GenericWhitespace"/>-->

<!-- ##### Blank line requirements ##### -->
<module name="EmptyLineSeparator">
Expand Down
19 changes: 17 additions & 2 deletions core-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<lombok.version>1.18.30</lombok.version>
<google-gson.version>2.10.1</google-gson.version>
<google.guava.version>33.0.0-jre</google.guava.version>
<google-truth.version>1.4.1</google-truth.version>
<google-truth.version>1.4.2</google-truth.version>
<apache-commons-text.version>1.11.0</apache-commons-text.version>
<commons-io.version>2.15.1</commons-io.version>
<json-path.version>2.9.0</json-path.version>
Expand All @@ -54,7 +54,7 @@
<maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
<maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
<codestyle.version>1.1.0</codestyle.version>
<checkstyle.version>10.13.0</checkstyle.version>
<checkstyle.version>10.14.0</checkstyle.version>
<aspectj.version>1.9.21.1</aspectj.version>
<poi.version>5.2.5</poi.version>
<suite-name>testng-api</suite-name>
Expand Down Expand Up @@ -91,6 +91,21 @@
<url>https://github.com/BoykaFramework</url>
</organization>

<contributors>
<contributor>
<name>Wasiq Bhamla</name>
<email>[email protected]</email>
<roles>
<role>Project Lead</role>
<role>Project Maintainer</role>
</roles>
<organization>Boyka Framework</organization>
<organizationUrl>https://github.com/BoykaFramework</organizationUrl>
<timezone>+5</timezone>
<url>https://github.com/WasiqB</url>
</contributor>
</contributors>

<licenses>
<license>
<name>MIT License</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static io.github.boykaframework.utils.ErrorHandler.handleAndThrow;
import static java.text.MessageFormat.format;
import static java.time.Duration.ofMillis;
import static java.util.Objects.isNull;
import static org.apache.logging.log4j.LogManager.getLogger;

import java.util.Collection;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static <D extends WebDriver, E> E getDriverAttribute (final Function<D, E
try {
return LOGGER.traceExit (action.apply ((D) getSession ().getDriver ()));
} catch (final FrameworkError e) {
if (defaultValue != null) {
if (!isNull (defaultValue)) {
return defaultValue;
} else {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static java.lang.String.join;
import static java.text.MessageFormat.format;
import static java.time.Duration.ofSeconds;
import static java.util.Objects.isNull;
import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNullElse;
import static java.util.Optional.ofNullable;
Expand Down Expand Up @@ -146,7 +147,7 @@ private void addHeader (final String name, final String value) {
}

private ApiActions basicAuth (final String userName, final String password) {
if (userName != null) {
if (!isNull (userName)) {
LOGGER.traceEntry ("Parameters: userName={}", userName);
final var credentials = basic (userName,
requireNonNull (password, AUTH_PASSWORD_REQUIRED.getMessageText ()));
Expand All @@ -157,7 +158,7 @@ private ApiActions basicAuth (final String userName, final String password) {

private <T> ApiActions body (final T body) {
LOGGER.traceEntry ();
if (body != null) {
if (!isNull (body)) {
body (JsonUtil.toString (body));
}
return LOGGER.traceExit (this);
Expand Down Expand Up @@ -343,7 +344,7 @@ private ApiRequest parseRequest (final Request request) {

private ApiResponse parseResponse (final Response res) {
LOGGER.traceEntry ();
if (res == null) {
if (isNull (res)) {
return null;
}
final var headers = new HashMap<String, String> ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static java.lang.System.getProperty;
import static java.lang.Thread.currentThread;
import static java.text.MessageFormat.format;
import static java.util.Objects.isNull;
import static java.util.Optional.ofNullable;
import static org.apache.logging.log4j.LogManager.getLogger;

Expand Down Expand Up @@ -109,7 +110,7 @@ public void saveLogs () {
.getAvailableLogTypes ();
logTypes.forEach (logType -> {
LOGGER.info ("Saving [{}] logs to a file...", logType);
if (logSetting.getExcludeLogs () == null || !logSetting.getExcludeLogs ()
if (isNull (logSetting.getExcludeLogs ()) || !logSetting.getExcludeLogs ()
.contains (logType)) {
saveLogType (d, logType, logSetting.getPath ());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static io.github.boykaframework.enums.Message.ELEMENT_NOT_FOUND;
import static io.github.boykaframework.manager.ParallelSession.getSession;
import static java.text.MessageFormat.format;
import static java.util.Objects.isNull;
import static java.util.Objects.requireNonNull;
import static org.apache.logging.log4j.LogManager.getLogger;
import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable;
Expand Down Expand Up @@ -58,7 +59,7 @@ public static WebElement find (final Locator locator, final WaitStrategy waitStr
if (elements.isEmpty ()) {
ErrorHandler.throwError (ELEMENT_NOT_FOUND, locator.getName (), getSession ().getPlatformType ());
}
if (locator.getFilter () != null) {
if (!isNull (locator.getFilter ())) {
return elements.stream ()
.filter (locator.getFilter ())
.findFirst ()
Expand All @@ -80,7 +81,7 @@ public static List<WebElement> finds (final Locator locator, final WaitStrategy
LOGGER.traceEntry ();
final var driver = getSession ().getDriver ();
final List<WebElement> elements;
if (locator.getParent () != null) {
if (!isNull (locator.getParent ())) {
final var parent = find (locator.getParent (), waitStrategy);
elements = finds (driver, parent, locator);
} else {
Expand All @@ -94,11 +95,12 @@ private static <D extends WebDriver> List<WebElement> finds (final D driver, fin
final Locator locator) {
LOGGER.traceEntry ();
final var platformLocator = locator.getLocator ();
if (platformLocator == null) {
if (isNull (platformLocator)) {
ErrorHandler.throwError (ELEMENT_NOT_FOUND, locator.getName (), getSession ().getPlatformType ());
}
return LOGGER.traceExit (
parent != null ? parent.findElements (locator.getLocator ()) : driver.findElements (locator.getLocator ()));
return LOGGER.traceExit (!isNull (parent)
? parent.findElements (locator.getLocator ())
: driver.findElements (locator.getLocator ()));
}

private static <D extends WebDriver> List<WebElement> finds (final D driver, final Locator locator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static java.time.Duration.ZERO;
import static java.time.Duration.ofMillis;
import static java.time.Duration.ofSeconds;
import static java.util.Objects.isNull;
import static org.openqa.selenium.interactions.PointerInput.Kind.TOUCH;
import static org.openqa.selenium.interactions.PointerInput.MouseButton.LEFT;
import static org.openqa.selenium.interactions.PointerInput.Origin.viewport;
Expand Down Expand Up @@ -103,7 +104,7 @@ private void checkCoordinateBounds (final Point point, final Locator locator) {
var w = SCREEN_SIZE.getWidth ();
var h = SCREEN_SIZE.getHeight ();

if (locator != null) {
if (!isNull (locator)) {
final var element = find (locator, WaitStrategy.CLICKABLE);
final var size = element.getSize ();
final var location = element.getLocation ();
Expand Down Expand Up @@ -171,7 +172,7 @@ private Point getSwipeEndPosition (final Point start) {
}

private Point getSwipeStartPosition () {
if (this.sourceElement != null) {
if (!isNull (this.sourceElement)) {
return getElementCenter (this.sourceElement);
}
return getScreenCenter ();
Expand All @@ -182,7 +183,7 @@ private Sequence singleFingerGesture (final Point start, final Point end) {
steps.addAction (finger.createPointerMove (ZERO, this.viewport, start.getX (), start.getY ()));
steps.addAction (finger.createPointerDown (LEFT.asArg ()));
steps.addAction (new Pause (finger, this.pause));
if (end != null) {
if (!isNull (end)) {
steps.addAction (finger.createPointerMove (this.speed, this.viewport, end.getX (), end.getY ()));
}
steps.addAction (finger.createPointerUp (LEFT.asArg ()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class UISetting {
private LogSetting logging = new LogSetting ();
private Map<String, MobileSetting> mobile;
private ScreenshotSetting screenshot = new ScreenshotSetting ();
private TimeoutSetting timeout = new TimeoutSetting ();
private Map<String, WebSetting> web;
private TimeoutSetting timeout = new TimeoutSetting ();
private Map<String, WebSetting> web;

/**
* Get Mobile settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package io.github.boykaframework.config.ui.web;

import static io.github.boykaframework.enums.Browser.NONE;
import static io.github.boykaframework.enums.Protocol.HTTP;
import static io.github.boykaframework.enums.TargetProviders.LOCAL;
import static io.github.boykaframework.enums.WindowResizeType.NORMAL;
import static io.github.boykaframework.utils.StringUtils.interpolate;

import java.util.List;
Expand All @@ -38,7 +41,7 @@
@Data
public class WebSetting {
private String baseUrl;
private Browser browser = Browser.NONE;
private Browser browser = NONE;
private List<String> browserOptions;
private Map<String, Object> capabilities;
private Dimension customSize = new Dimension (1920, 1080);
Expand All @@ -49,9 +52,10 @@ public class WebSetting {
private String platform;
private int port;
private Protocol protocol = HTTP;
private WindowResizeType resize = WindowResizeType.NORMAL;
private TargetProviders target;
private WindowResizeType resize = NORMAL;
private TargetProviders target = LOCAL;
private String userName;
private String version = "stable";

/**
* Gets cloud password.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import static io.appium.java_client.Setting.IGNORE_UNIMPORTANT_VIEWS;
import static io.github.boykaframework.enums.AutomationType.UI_AUTOMATOR;
import static io.github.boykaframework.enums.DeviceType.VIRTUAL;
import static java.time.Duration.ofSeconds;
import static java.util.Objects.isNull;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
Expand Down Expand Up @@ -71,7 +73,7 @@ private void setAndroidApplicationOptions (final UiAutomator2Options options,

private void setAvdOptions (final UiAutomator2Options options, final DeviceType type,
final VirtualDeviceSetting avd) {
if (type == DeviceType.VIRTUAL && avd != null) {
if (type == VIRTUAL && !isNull (avd)) {
options.setAvd (avd.getName ());
options.setIsHeadless (avd.isHeadless ());
options.setAvdLaunchTimeout (ofSeconds (avd.getLaunchTimeout ()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.boykaframework.manager;

import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.apache.logging.log4j.LogManager.getLogger;

Expand Down Expand Up @@ -126,7 +127,7 @@ public <T extends BoykaListener> T getListener (final ListenerType listenerType)
loadAllListeners ();
}
final var listener = this.listeners.get (listenerType);
if (listener == null) {
if (isNull (listener)) {
return null;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static io.github.boykaframework.enums.TargetProviders.LOCAL;
import static java.lang.System.getProperty;
import static java.text.MessageFormat.format;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;

import java.nio.file.Path;
Expand Down Expand Up @@ -56,7 +57,7 @@ default <E extends BaseOptions<E>, T extends SupportsAppOption<E>> void setupApp

default <E extends MutableCapabilities> void setupCloudDriverOptions (final E options,
final Map<String, Object> capabilities, final TargetProviders targetProviders) {
if (capabilities != null && targetProviders != LOCAL) {
if (!isNull (capabilities) && targetProviders != LOCAL) {
final var optionCapabilities = new HashMap<String, Object> ();
capabilities.forEach ((k, v) -> {
if (v instanceof String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static io.github.boykaframework.utils.ErrorHandler.handleAndThrow;
import static io.github.boykaframework.utils.Validator.setOptionIfPresent;
import static java.time.Duration.ofSeconds;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;

import io.appium.java_client.ios.IOSDriver;
Expand Down Expand Up @@ -89,7 +90,7 @@ private void setCommonCapabilities (final XCUITestOptions options) {
}

private void setWdaOptions (final WDASetting wda, final XCUITestOptions options) {
if (wda != null) {
if (!isNull (wda)) {
setOptionIfPresent (wda.getLocalPort (), options::setWdaLocalPort);
options.setUseNewWDA (wda.isUseNew ());
setOptionIfPresent (wda.getLaunchTimeout (), v -> options.setWdaLaunchTimeout (ofSeconds (v)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static io.github.boykaframework.utils.ErrorHandler.throwError;
import static io.github.boykaframework.utils.Validator.requireNonEmpty;
import static java.lang.ThreadLocal.withInitial;
import static java.util.Objects.isNull;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.StringUtils.isEmpty;
Expand Down Expand Up @@ -161,7 +162,7 @@ public static boolean isSessionCreated () {
*/
public static void switchPersona (final String persona) {
final var currentPersona = getCurrentPersona ();
if (currentPersona != null && currentPersona.equals (
if (!isNull (currentPersona) && currentPersona.equals (
requireNonEmpty (persona, SESSION_PERSONA_CANNOT_BE_NULL))) {
return;
}
Expand Down
Loading