diff --git a/LICENSE b/LICENSE
index ff1b7cb..df21359 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2019 Aquality Automation
+ Copyright 2022 Aquality Automation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index 2f13860..a8dce51 100644
--- a/README.md
+++ b/README.md
@@ -13,13 +13,16 @@ Most of performed methods are logged using LOG4J, so you can easily see a histor
We use interfaces where is possible, so you can implement your own version of target interface with no need to rewrite other classes.
### Quick start
+To start the project using aquality.selenium framework, you can [download our template BDD project by this link.](https://github.com/aquality-automation/aquality-selenium-java-template)
-1. To start work with this package, simply add the dependency to your pom.xml:
+Alternatively, you can follow the steps below:
+
+1. Add the dependency to your pom.xml:
```
com.github.aquality-automation
aquality-selenium
- LATEST
+ 3.x.x
```
@@ -47,14 +50,37 @@ txbSearch.submit();
browser.waitForPageToLoad();
```
-6. Quit browser at the end
+6. Use BiDi functionality to handle basic authentication:
+```java
+browser.network().addBasicAuthentication("domain.com", "username", "password");
```
+or intercept network requests/responses:
+```java
+browser.network().startNetworkInterceptor((HttpHandler) request -> new HttpResponse()
+ .setStatus(HttpStatus.SC_OK)
+ .addHeader("Content-Type", MediaType.HTML_UTF_8.toString())
+ .setContent(utf8String("Some phrase")));
+```
+7. Emulate GeoLocation, Device, Touch, Media, UserAgent overrides, Disable script execution, log HTTP exchange, track Performance metrics, add initialization scripts, and more using browser.devTools() interfaces:
+```java
+final double latitude = 53.90772672521578;
+final double longitude = 27.458060411865375;
+final double accuracy = 0.97;
+browser.devTools().emulation().setGeolocationOverride(latitude, longitude, accuracy);
+```
+See more DevTools use cases [here](./src/test/java/tests/usecases/devtools)
+
+8. Quit browser at the end
+```java
browser.quit();
```
-See full example [here](./src/test/java/tests/usecases/QuickStartExample.java)
+See quick start example [here](./src/test/java/tests/usecases/QuickStartExample.java)
### Documentation
To get more details please look at documentation:
- [In English](https://github.com/aquality-automation/aquality-selenium-java/wiki/Overview-(English))
- [In Russian](https://github.com/aquality-automation/aquality-selenium-java/wiki/Overview-(Russian))
+
+### License
+Library's source code is made available under the [Apache 2.0 license](LICENSE).
diff --git a/pom.xml b/pom.xml
index 109371a..dcbd724 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.github.aquality-automation
aquality-selenium
- 3.0.0
+ 3.1.0
jar
Aquality Selenium
Library around Selenium WebDriver
@@ -81,31 +81,25 @@
com.github.aquality-automation
aquality-selenium-core
- 2.0.1
-
-
-
- org.seleniumhq.selenium
- selenium-java
- 4.1.0
+ 2.0.4
io.github.bonigarcia
webdrivermanager
- 5.0.2
+ 5.3.0
com.fasterxml.jackson.core
jackson-databind
- 2.13.0
+ 2.13.4
org.testng
testng
- 6.14.3
+ 7.5
test
diff --git a/src/main/java/aquality/selenium/browser/Browser.java b/src/main/java/aquality/selenium/browser/Browser.java
index 18fdac2..e3dcedc 100644
--- a/src/main/java/aquality/selenium/browser/Browser.java
+++ b/src/main/java/aquality/selenium/browser/Browser.java
@@ -1,5 +1,8 @@
package aquality.selenium.browser;
+import aquality.selenium.browser.devtools.DevToolsHandling;
+import aquality.selenium.browser.devtools.JavaScriptHandling;
+import aquality.selenium.browser.devtools.NetworkHandling;
import aquality.selenium.configuration.IBrowserProfile;
import aquality.selenium.configuration.ITimeoutConfiguration;
import aquality.selenium.core.applications.IApplication;
@@ -7,12 +10,12 @@
import aquality.selenium.core.localization.ILocalizedLogger;
import aquality.selenium.core.waitings.IConditionalWait;
import org.apache.commons.io.IOUtils;
-import org.openqa.selenium.Alert;
-import org.openqa.selenium.Dimension;
-import org.openqa.selenium.NoAlertPresentException;
-import org.openqa.selenium.OutputType;
+import org.apache.commons.lang3.NotImplementedException;
+import org.openqa.selenium.*;
import org.openqa.selenium.WebDriver.Navigation;
+import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.logging.LogEntries;
+import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
@@ -20,7 +23,6 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
-import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
public class Browser implements IApplication {
@@ -32,6 +34,7 @@ public class Browser implements IApplication {
private final ILocalizationManager localizationManager;
private final ILocalizedLogger localizedLogger;
+ private DevToolsHandling devTools;
private Duration implicitTimeout;
public Browser(RemoteWebDriver remoteWebDriver) {
@@ -262,6 +265,17 @@ public Object executeScript(final String script, Object... arguments) {
return executeJavaScript(() -> getDriver().executeScript(script, arguments));
}
+ /**
+ * Executes JS (jQuery) script.
+ *
+ * @param script Script pinned with {@link this#javaScriptEngine()}.
+ * @param arguments Arguments for the script (web elements, values etc.
+ * @return Result object of script execution
+ */
+ public Object executeScript(final ScriptKey script, Object... arguments) {
+ return executeJavaScript(() -> getDriver().executeScript(script, arguments));
+ }
+
private Object executeJavaScript(Supplier