From d25bf97aefd7d965333fe8171b55314c7d26ce80 Mon Sep 17 00:00:00 2001
From: MiriamKyoseva <133047546+MiriamKyoseva@users.noreply.github.com>
Date: Fri, 31 Jan 2025 11:33:42 +0200
Subject: [PATCH 1/3] adding a new method to NavigationService: to(WebPage
page)
---
.../java/solutions/bellatrix/playwright/pages/WebPage.java | 2 +-
.../bellatrix/playwright/services/NavigationService.java | 5 +++++
.../src/main/java/solutions/bellatrix/web/pages/WebPage.java | 2 +-
.../solutions/bellatrix/web/services/NavigationService.java | 5 +++++
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java
index 963ec93b..15902ff9 100644
--- a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java
+++ b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java
@@ -36,7 +36,7 @@ public NavigationService navigate() {
return SingletonFactory.getInstance(NavigationService.class);
}
- protected String getUrl() {
+ public String getUrl() {
return "";
}
diff --git a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java
index daa099a5..6840c17f 100644
--- a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java
+++ b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java
@@ -15,6 +15,7 @@
import com.google.common.base.Strings;
import solutions.bellatrix.core.utilities.SingletonFactory;
+import solutions.bellatrix.playwright.pages.WebPage;
import java.net.MalformedURLException;
import java.net.URL;
@@ -28,6 +29,10 @@
@SuppressWarnings("ALL")
public class NavigationService extends WebService {
+ public void to(WebPage page) {
+ wrappedBrowser().getCurrentPage().navigate(page.getUrl());
+ }
+
public void to(String url) {
wrappedBrowser().getCurrentPage().navigate(url);
}
diff --git a/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java b/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java
index a2d9c490..c5b9542a 100644
--- a/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java
+++ b/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java
@@ -44,7 +44,7 @@ public NavigationService navigate() {
return new NavigationService();
}
- protected String getUrl() {
+ public String getUrl() {
return "";
}
diff --git a/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java b/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java
index cef9c96c..ed700e00 100644
--- a/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java
+++ b/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java
@@ -18,6 +18,7 @@
import org.openqa.selenium.support.ui.WebDriverWait;
import solutions.bellatrix.core.configuration.ConfigurationService;
import solutions.bellatrix.web.configuration.WebSettings;
+import solutions.bellatrix.web.pages.WebPage;
import java.net.MalformedURLException;
import java.net.URL;
@@ -37,6 +38,10 @@ public void to(String url) {
getWrappedDriver().navigate().to(url);
}
+ public void to(WebPage page) {
+ getWrappedDriver().navigate().to(page.getUrl());
+ }
+
public void toLocalPage(String filePath) {
URL testAppUrl = Thread.currentThread().getContextClassLoader().getResource(filePath);
if (testAppUrl != null) {
From f2ca51ce6ce4a43d6ab79f49bd15349473217664 Mon Sep 17 00:00:00 2001
From: MiriamKyoseva <133047546+MiriamKyoseva@users.noreply.github.com>
Date: Fri, 31 Jan 2025 11:34:01 +0200
Subject: [PATCH 2/3] getting started for visual regression tracker
---
.../plugins/vrt/VisualRegressionService.java | 1 +
.../pom.xml | 6 ++
.../VisualRegressionTests.java | 61 ++++++++++++++++++
.../data/MobileServiceAssertions.java | 6 ++
.../data/MobileServiceMap.java | 10 +++
.../data/MobileServicePage.java | 10 +++
.../bellatrix.web.getting.started/pom.xml | 6 ++
.../resources/testFrameworkSettings.dev.json | 11 ++++
.../VisualRegressionTests.java | 64 +++++++++++++++++++
.../data/MobileServiceAssertions.java | 6 ++
.../data/MobileServiceMap.java | 10 +++
.../data/MobileServicePage.java | 10 +++
12 files changed, 201 insertions(+)
create mode 100644 getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java
create mode 100644 getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java
create mode 100644 getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java
create mode 100644 getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java
create mode 100644 getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java
create mode 100644 getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java
create mode 100644 getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java
create mode 100644 getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java
diff --git a/bellatrix.plugins.visual-regression-tracker/src/main/java/solutions/bellatrix/plugins/vrt/VisualRegressionService.java b/bellatrix.plugins.visual-regression-tracker/src/main/java/solutions/bellatrix/plugins/vrt/VisualRegressionService.java
index ad660a35..eeefd6eb 100644
--- a/bellatrix.plugins.visual-regression-tracker/src/main/java/solutions/bellatrix/plugins/vrt/VisualRegressionService.java
+++ b/bellatrix.plugins.visual-regression-tracker/src/main/java/solutions/bellatrix/plugins/vrt/VisualRegressionService.java
@@ -76,6 +76,7 @@ public static TestRunResult track(String name) {
public static String takeSnapshot(String name) {
var screenshotPlugin = SingletonFactory.getInstance(ScreenshotPlugin.class);
+
if (screenshotPlugin == null) {
throw new IllegalArgumentException("It seems that the screenshot plugin isn't registered by the 'ScreenshotPlugin.class' key inside SingletonFactory's map or isn't registered at all!");
}
diff --git a/getting-started/bellatrix.playwright.getting.started/pom.xml b/getting-started/bellatrix.playwright.getting.started/pom.xml
index 01492435..77ea044f 100644
--- a/getting-started/bellatrix.playwright.getting.started/pom.xml
+++ b/getting-started/bellatrix.playwright.getting.started/pom.xml
@@ -45,6 +45,12 @@
1.0
compile
+
+ solutions.bellatrix
+ bellatrix.plugins.visual-regression-tracker
+ 1.0-SNAPSHOT
+ test
+
\ No newline at end of file
diff --git a/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java
new file mode 100644
index 00000000..c878368c
--- /dev/null
+++ b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java
@@ -0,0 +1,61 @@
+package O25_visual_regression_tracker;
+
+import O25_visual_regression_tracker.data.MobileServicePage;
+import org.junit.jupiter.api.Test;
+import solutions.bellatrix.playwright.infrastructure.junit.WebTest;
+import solutions.bellatrix.plugins.vrt.VisualRegression;
+import solutions.bellatrix.plugins.vrt.VisualRegressionAssertions;
+import solutions.bellatrix.plugins.vrt.VisualRegressionPlugin;
+/*
+ To begin tracking visual regression with BELLATRIX, one must have this in the config file:
+ "visualRegressionSettings": {
+ "apiUrl": "", (REQUIRED)
+ "apiKey": "", (REQUIRED)
+ "project": "", (REQUIRED)
+ "branch": "vrt", (REQUIRED)
+ "enableSoftAssert": "true", (REQUIRED)
+ "ciBuildId": "vrt", (REQUIRED)
+ "httpTimeout": "15", (REQUIRED)
+ "defaultDiffTolerance": "0.1" (REQUIRED)
+ }
+
+ These settings are all required to start. After we have set them, we can then begin.
+ */
+
+// To mark a test class for visual regression, we simply use @VisualRegression annotation
+// One can also provide the VRT project name and the resolution, otherwise default values will be used
+@VisualRegression
+public class VisualRegressionTests extends WebTest {
+ protected void configure() {
+ super.configure();
+ addPlugin(VisualRegressionPlugin.class);
+
+ // it is also important to have the screenshot plugin registered as the base class
+ // addPluginAs(ScreenshotPlugin.class, WebScreenshotPlugin.class);
+ // check in your base test if it is registered as that
+ }
+ // We need @VisualRegression annotation so that the tracker process could start at the beginning of the test
+ // and be ready for use in said test.
+ // After the test is over, the tracker is closed.
+
+ @Test
+ public void visualRegressionTest_using_assertions() {
+ app().navigate().to("https://www.automatetheplanet.com/services/web-automation/");
+
+ VisualRegressionAssertions.assertSameAsBaseline("web-automation-service-page");
+ // This is the simplest way to start using VRT: by inserting a visual regression assertion method
+ // here, the name required is the name of the baseline
+ }
+
+ @Test
+ @VisualRegression // If only one of our tests is for visual regression tracking,
+ // the @VisualRegression annotation can be used on the method instead
+ public void visualRegressionTest_using_assertByPageObjectModel() {
+ var mobileServicePage = new MobileServicePage();
+
+ app().navigate().to(mobileServicePage);
+
+ // If our baseline has the same name as the POM, we can just pass the POM.
+ VisualRegressionAssertions.assertSameAsBaseline(mobileServicePage);
+ }
+}
\ No newline at end of file
diff --git a/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java
new file mode 100644
index 00000000..cc2ab64b
--- /dev/null
+++ b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java
@@ -0,0 +1,6 @@
+package O25_visual_regression_tracker.data;
+
+import solutions.bellatrix.playwright.pages.PageAsserts;
+
+public class MobileServiceAssertions extends PageAsserts {
+}
diff --git a/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java
new file mode 100644
index 00000000..cf0d08c6
--- /dev/null
+++ b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java
@@ -0,0 +1,10 @@
+package O25_visual_regression_tracker.data;
+
+import solutions.bellatrix.playwright.components.Div;
+import solutions.bellatrix.playwright.pages.PageMap;
+
+public class MobileServiceMap extends PageMap {
+ public Div rightPeopleSection() {
+ return app().create().byId(Div.class, "right-people-section bottom-40");
+ }
+}
diff --git a/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java
new file mode 100644
index 00000000..28238bdd
--- /dev/null
+++ b/getting-started/bellatrix.playwright.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java
@@ -0,0 +1,10 @@
+package O25_visual_regression_tracker.data;
+
+import solutions.bellatrix.playwright.pages.WebPage;
+
+public class MobileServicePage extends WebPage {
+ @Override
+ public String getUrl() {
+ return "https://www.automatetheplanet.com/services/mobile-automation/";
+ }
+}
diff --git a/getting-started/bellatrix.web.getting.started/pom.xml b/getting-started/bellatrix.web.getting.started/pom.xml
index 8f737216..b5dc88f2 100644
--- a/getting-started/bellatrix.web.getting.started/pom.xml
+++ b/getting-started/bellatrix.web.getting.started/pom.xml
@@ -50,6 +50,12 @@
5.9.2
test
+
+ solutions.bellatrix
+ bellatrix.plugins.visual-regression-tracker
+ 1.0-SNAPSHOT
+ test
+
\ No newline at end of file
diff --git a/getting-started/bellatrix.web.getting.started/src/main/resources/testFrameworkSettings.dev.json b/getting-started/bellatrix.web.getting.started/src/main/resources/testFrameworkSettings.dev.json
index 589ce73d..d793e386 100644
--- a/getting-started/bellatrix.web.getting.started/src/main/resources/testFrameworkSettings.dev.json
+++ b/getting-started/bellatrix.web.getting.started/src/main/resources/testFrameworkSettings.dev.json
@@ -2,6 +2,16 @@
"troubleshootingSettings": {
"debugInformationEnabled": "true"
},
+ "visualRegressionSettings": {
+ "apiUrl": "http://localhost:4200",
+ "apiKey": "DEFAULTUSERAPIKEYTOBECHANGED",
+ "project": "vrt",
+ "branch": "bellatrix-tests",
+ "enableSoftAssert": "true",
+ "ciBuildId": "local-automation-run",
+ "httpTimeout": "15",
+ "defaultDiffTolerance": "0.1"
+ },
"webSettings": {
"baseUrl": "http://demos.bellatrix.solutions/",
"executionType":"regular",
@@ -17,6 +27,7 @@
"screenshotsSaveLocation": "${user.home}/BELLATRIX/Screenshots",
"videosOnFailEnabled": "false",
"videosSaveLocation": "${user.home}/BELLATRIX/Videos",
+ "toastNotificationBddLogging": "false",
"timeoutSettings": {
"elementWaitTimeout": "30",
"pageLoadTimeout": "30",
diff --git a/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java
new file mode 100644
index 00000000..3167467d
--- /dev/null
+++ b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/VisualRegressionTests.java
@@ -0,0 +1,64 @@
+package O25_visual_regression_tracker;
+
+import O25_visual_regression_tracker.data.MobileServiceMap;
+import O25_visual_regression_tracker.data.MobileServicePage;
+import org.junit.jupiter.api.Test;
+import plugins.screenshots.ScreenshotPlugin;
+import solutions.bellatrix.plugins.vrt.VisualRegression;
+import solutions.bellatrix.plugins.vrt.VisualRegressionAssertions;
+import solutions.bellatrix.plugins.vrt.VisualRegressionPlugin;
+import solutions.bellatrix.web.infrastructure.WebScreenshotPlugin;
+import solutions.bellatrix.web.infrastructure.junit.WebTest;
+/*
+ To begin tracking visual regression with BELLATRIX, one must have this in the config file:
+ "visualRegressionSettings": {
+ "apiUrl": "", (REQUIRED)
+ "apiKey": "", (REQUIRED)
+ "project": "", (REQUIRED)
+ "branch": "vrt", (REQUIRED)
+ "enableSoftAssert": "true", (REQUIRED)
+ "ciBuildId": "vrt", (REQUIRED)
+ "httpTimeout": "15", (REQUIRED)
+ "defaultDiffTolerance": "0.1" (REQUIRED)
+ }
+
+ These settings are all required to start. After we have set them, we can then begin.
+ */
+
+// To mark a test class for visual regression, we simply use @VisualRegression annotation
+// One can also provide the VRT project name and the resolution, otherwise default values will be used
+@VisualRegression
+public class VisualRegressionTests extends WebTest {
+ protected void configure() {
+ super.configure();
+ addPlugin(VisualRegressionPlugin.class);
+
+ // it is also important to have the screenshot plugin registered as the base class
+ // addPluginAs(ScreenshotPlugin.class, WebScreenshotPlugin.class);
+ // check in your base test if it is registered as that
+ }
+ // We need @VisualRegression annotation so that the tracker process could start at the beginning of the test
+ // and be ready for use in said test.
+ // After the test is over, the tracker is closed.
+
+ @Test
+ public void visualRegressionTest_using_assertions() {
+ app().navigate().to("https://www.automatetheplanet.com/services/web-automation/");
+
+ VisualRegressionAssertions.assertSameAsBaseline("web-automation-service-page");
+ // This is the simplest way to start using VRT: by inserting a visual regression assertion method
+ // here, the name required is the name of the baseline
+ }
+
+ @Test
+ @VisualRegression // If only one of our tests is for visual regression tracking,
+ // the @VisualRegression annotation can be used on the method instead
+ public void visualRegressionTest_using_assertByPageObjectModel() {
+ var mobileServicePage = new MobileServicePage();
+
+ app().navigate().to(mobileServicePage);
+
+ // If our baseline has the same name as the POM, we can just pass the POM.
+ VisualRegressionAssertions.assertSameAsBaseline(mobileServicePage);
+ }
+}
\ No newline at end of file
diff --git a/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java
new file mode 100644
index 00000000..dd45bc39
--- /dev/null
+++ b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceAssertions.java
@@ -0,0 +1,6 @@
+package O25_visual_regression_tracker.data;
+
+import solutions.bellatrix.web.pages.PageAsserts;
+
+public class MobileServiceAssertions extends PageAsserts {
+}
diff --git a/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java
new file mode 100644
index 00000000..ec5f76c4
--- /dev/null
+++ b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServiceMap.java
@@ -0,0 +1,10 @@
+package O25_visual_regression_tracker.data;
+
+import solutions.bellatrix.web.components.Div;
+import solutions.bellatrix.web.pages.PageMap;
+
+public class MobileServiceMap extends PageMap {
+ public Div rightPeopleSection() {
+ return app().create().byId(Div.class, "right-people-section bottom-40");
+ }
+}
diff --git a/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java
new file mode 100644
index 00000000..f7090ee7
--- /dev/null
+++ b/getting-started/bellatrix.web.getting.started/src/test/java/O25_visual_regression_tracker/data/MobileServicePage.java
@@ -0,0 +1,10 @@
+package O25_visual_regression_tracker.data;
+
+import solutions.bellatrix.web.pages.WebPage;
+
+public class MobileServicePage extends WebPage {
+ @Override
+ public String getUrl() {
+ return "https://www.automatetheplanet.com/services/mobile-automation/";
+ }
+}
From c306fe686cbdb7c9a59418d93184fd5bd4e850ed Mon Sep 17 00:00:00 2001
From: MiriamKyoseva
Date: Fri, 31 Jan 2025 12:27:09 +0200
Subject: [PATCH 3/3] revert making getUrl public, added workaround with
reflection
---
.../solutions/bellatrix/playwright/pages/WebPage.java | 2 +-
.../bellatrix/playwright/services/NavigationService.java | 7 ++++++-
.../main/java/solutions/bellatrix/web/pages/WebPage.java | 2 +-
.../bellatrix/web/services/NavigationService.java | 8 +++++++-
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java
index 15902ff9..963ec93b 100644
--- a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java
+++ b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/pages/WebPage.java
@@ -36,7 +36,7 @@ public NavigationService navigate() {
return SingletonFactory.getInstance(NavigationService.class);
}
- public String getUrl() {
+ protected String getUrl() {
return "";
}
diff --git a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java
index 6840c17f..21470fde 100644
--- a/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java
+++ b/bellatrix.playwright/src/main/java/solutions/bellatrix/playwright/services/NavigationService.java
@@ -14,9 +14,11 @@
package solutions.bellatrix.playwright.services;
import com.google.common.base.Strings;
+import lombok.SneakyThrows;
import solutions.bellatrix.core.utilities.SingletonFactory;
import solutions.bellatrix.playwright.pages.WebPage;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
@@ -29,8 +31,11 @@
@SuppressWarnings("ALL")
public class NavigationService extends WebService {
+ @SneakyThrows
public void to(WebPage page) {
- wrappedBrowser().getCurrentPage().navigate(page.getUrl());
+ Method method = page.getClass().getDeclaredMethod("getUrl");
+ method.setAccessible(true);
+ wrappedBrowser().getCurrentPage().navigate((String)method.invoke(page));
}
public void to(String url) {
diff --git a/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java b/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java
index c5b9542a..a2d9c490 100644
--- a/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java
+++ b/bellatrix.web/src/main/java/solutions/bellatrix/web/pages/WebPage.java
@@ -44,7 +44,7 @@ public NavigationService navigate() {
return new NavigationService();
}
- public String getUrl() {
+ protected String getUrl() {
return "";
}
diff --git a/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java b/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java
index ed700e00..75bb5f3a 100644
--- a/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java
+++ b/bellatrix.web/src/main/java/solutions/bellatrix/web/services/NavigationService.java
@@ -14,12 +14,14 @@
package solutions.bellatrix.web.services;
import com.google.common.base.Strings;
+import lombok.SneakyThrows;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.support.ui.WebDriverWait;
import solutions.bellatrix.core.configuration.ConfigurationService;
import solutions.bellatrix.web.configuration.WebSettings;
import solutions.bellatrix.web.pages.WebPage;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
@@ -38,8 +40,12 @@ public void to(String url) {
getWrappedDriver().navigate().to(url);
}
+ @SneakyThrows
public void to(WebPage page) {
- getWrappedDriver().navigate().to(page.getUrl());
+ Method method = page.getClass().getDeclaredMethod("getUrl");
+ method.setAccessible(true);
+
+ getWrappedDriver().navigate().to((String)method.invoke(page));
}
public void toLocalPage(String filePath) {