diff --git a/.gitignore b/.gitignore
index d7c24dc..25b7f9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,6 @@
/.project
/.idea/
*.iml
-.DS_Store
\ No newline at end of file
+.DS_Store
+/video/
+/screenshots/
\ No newline at end of file
diff --git a/.talismanrc b/.talismanrc
index e79dc87..f805cb3 100644
--- a/.talismanrc
+++ b/.talismanrc
@@ -13,4 +13,28 @@ fileignoreconfig:
ignore_detectors: []
- filename: README.md
checksum: 74c3a77b9495fed2bb3a07ce4987a4e1c3b770424fae8db5c8e67d7676d7c493
+ ignore_detectors: []
+- filename: src/main/java/com/github/wasiqb/coteafs/selenium/config/RemoteSetting.java
+ checksum: 2f4a2cf1585bfd180da2683ce0942eecd0de56c9b0fe2bf0cbb0303110c5c3eb
+ ignore_detectors: []
+- filename: src/main/java/com/github/wasiqb/coteafs/selenium/core/Browser.java
+ checksum: 2e8af12fd8145fe506ddf9ea103bf50d8df95021aae044b71596b90e7b1d1aeb
+ ignore_detectors: []
+- filename: src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/LoginPageAction.java
+ checksum: 786578aeddda9290a9a5eb3428ea4390351f87e2d0eafca1058923288a81f871
+ ignore_detectors: []
+- filename: src/test/resources/selenium-config.yaml
+ checksum: b3293363ab6b20b55ada0c25797bd1827e3904d2c7e4ef4d94bd8b293feda1ca
+ ignore_detectors: []
+- filename: src/test/resources/selenium-sauce-config.yaml
+ checksum: 6c141b0be18f5a439ddea042eb94f156af996ca1760e843a3526218ca4d9503a
+ ignore_detectors: []
+- filename: src/test/resources/selenium-bs-config.yaml
+ checksum: 2890d40eb5587fd295e6c8f83ceaffe8214ea41ff3b64596785b684e0f9f953f
+ ignore_detectors: []
+- filename: src/test/resources/selenium-grid-config.yaml
+ checksum: a705a7d6de2350861d9d37ae424bd97a89ec358c4ca7d7e108e1ab93d2dd0a5b
+ ignore_detectors: []
+- filename: README.md
+ checksum: 16f2f4ac5d186f1fc59f4a23f0860b324e9839b2e7d4f108ea8c4fee36a1c517
ignore_detectors: []
\ No newline at end of file
diff --git a/README.md b/README.md
index 607ba77..bb8718e 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ This is a Selenium WebDriver wrapper Framework which enables robust, maintainabl
Some of the key features which this framework offers are as follows:
-:point_right: Latest Selenium WebDriver 4.0 (Alpha 2).
+:point_right: Latest stable Selenium WebDriver 3.141.59.
:point_right: Minimal learning curve.
@@ -40,9 +40,11 @@ Some of the key features which this framework offers are as follows:
:point_right: On-demand highlighting of Elements.
+:point_right: On-demand video recording.
+
:point_right: On-demand delay of test execution by allowing predefined delays.
-:point_right: On-demand headless mode.
+:point_right: On-demand headless mode execution.
:point_right: Inline verification of elements.
@@ -62,14 +64,14 @@ You can use the following dependency into your `pom.xml` to use this library.
com.github.wasiqb.coteafs
selenium
- 3.0.0
+ 3.1.0
```
Or you can add the following into your `build.gradle` file.
```gradle
- compile "com.github.wasiqb.coteafs:selenium:3.0.0"
+ compile "com.github.wasiqb.coteafs:selenium:3.1.0"
```
## :smile: How it is easy to write Tests with this Framework?
@@ -121,9 +123,15 @@ playback: # Playback settings.
screen_resolution: # Screen resolution settings.
width: 1280 # Screen width.
height: 768 # Screen height.
+ recording:
+ enable: true # true, to enable recording, else false.
+ path: ./video # Video recording path.
+ prefix: VID # Video file prefix.
delays: # On demand delay settings.
implicit: 60 # Implicit waits in seconds.
explicit: 60 # Explicit waits in seconds.
+ after_frame_switch: 500 # Delay after iFrame switch in milliseconds.
+ after_window_switch: 500 # Delay after Window switch in milliseconds.
before_key_press: 0 # delay before key press in milliseconds.
after_key_press: 0 # delay after key press in milliseconds.
before_mouse_move: 0 # delay before mouse move in milliseconds.
@@ -138,6 +146,7 @@ playback: # Playback settings.
prefix: SCR # screenshot file prefix.
extension: jpeg # screenshot file extension.
capture_on_error: false # screenshot on error.
+ capture_all: true # always capture screenshot on each event, when true.
```
> **Note:** If you find any config not working, feel free to raise an [issue][].
@@ -165,19 +174,19 @@ import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions;
public class LoginPage extends BrowserPage {
public ITextboxActions password () {
- return form ().find (By.name ("password"));
+ return form ().find (By.name ("password"), "Password");
}
public IMouseActions signIn () {
- return form ().find (By.name ("btnLogin"));
+ return form ().find (By.name ("btnLogin"), "Login");
}
public ITextboxActions userId () {
- return form ().find (By.name ("uid"));
+ return form ().find (By.name ("uid"), "User ID");
}
private IMouseActions form () {
- return onClickable (By.name ("frmLogin"));
+ return onClickable (By.name ("frmLogin"), "Form");
}
}
```
@@ -205,7 +214,7 @@ import com.github.wasiqb.coteafs.selenium.pages.LoginPage;
import com.github.wasiqb.coteafs.selenium.pages.MainPage;
public class LoginPageAction extends AbstractPageAction {
- public static final String PASS = "password";
+ public static final String PASS = "password";
public static final String USER_ID = "userId";
@Override
@@ -218,8 +227,8 @@ public class LoginPageAction extends AbstractPageAction {
login.signIn ()
.click ();
- final MainPage main = new MainPage ();
- main.managerIdBanner ()
+ login.nextPage (MainPage.class)
+ .managerIdBanner ()
.verifyText ()
.endsWith (format ("Manger Id : {0}", value (USER_ID).toString ()));
}
@@ -266,7 +275,7 @@ public class SeleniumTest extends BrowserTest {
login.addInputValue (USER_ID, appSetting ().getParams ()
.get ("user"))
.addInputValue (PASS, appSetting ().getParams ()
- .get ("password"))
+ .get ("password"))
.perform ();
}
}
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
new file mode 100644
index 0000000..fecd31a
--- /dev/null
+++ b/checkstyle-suppressions.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 0000000..ee3cca1
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8dcd021..d1c680c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
selenium
- 3.0.0
+ 3.1.0
coteafs-selenium
Selenium WebDriver wrapper framework for clean and maintainable tests.
https://github.com/WasiqB/coteafs-selenium
@@ -11,7 +11,7 @@
com.github.wasiqb.coteafs
parent
- 2.2.0
+ 3.0.0
@@ -25,16 +25,31 @@
https://circleci.com/gh/WasiqB/coteafs-selenium
+
+
+
+ false
+
+ bintray-epam-reportportal
+ bintray
+ http://dl.bintray.com/epam/reportportal
+
+
+
- 1.8.0
- 1.7.0
- 1.8.0
- 1.2.0
- 4.0.0-alpha-2
+ 2.1.4
+ 1.11.0
+ 2.2.0
+ 2.2.0
+ 3.141.59
2.6
- 3.6.2
- 1.0.0
- 1.7
+ 3.7.1
+ 1.0.1
+ 1.8
+ 0.7.7.0
+ 1.18.10
+ 4.2.1
+ 4.0.1
@@ -42,12 +57,6 @@
com.github.wasiqb.coteafs
configs
${coteafs.config.version}
-
-
- org.yaml
- snakeyaml
-
-
com.github.wasiqb.coteafs
@@ -68,31 +77,31 @@
org.apache.commons
commons-text
${commons.text.version}
+ provided
org.testng
testng
${testng.version}
-
- org.yaml
- snakeyaml
-
com.google.guava
guava
+ provided
org.apache.commons
commons-lang3
${commons.version}
+ provided
commons-io
commons-io
${commons.io.version}
+ provided
com.google.truth
@@ -104,6 +113,7 @@
guava
+ provided
org.seleniumhq.selenium
@@ -114,16 +124,43 @@
io.github.bonigarcia
webdrivermanager
${webdrivermanager-version}
+ provided
com.google.guava
guava
${guava.version}
+ provided
com.github.javafaker
javafaker
${faker.version}
+ test
+
+
+ com.github.stephenc.monte
+ monte-screen-recorder
+ ${recorder.version}
+ provided
+
+
+ com.epam.reportportal
+ logger-java-log4j
+ ${report.log.version}
+ provided
+
+
+ com.epam.reportportal
+ agent-java-testng
+ ${report.agent.version}
+ provided
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ApplicationSetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ApplicationSetting.java
index b502372..6aa6e66 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ApplicationSetting.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ApplicationSetting.java
@@ -18,178 +18,37 @@
import java.util.HashMap;
import java.util.Map;
+import com.github.wasiqb.coteafs.config.util.BasePojo;
import com.github.wasiqb.coteafs.selenium.core.enums.AvailableBrowser;
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since Apr 8, 2018 2:41:06 PM
*/
-public class ApplicationSetting {
- private AvailableBrowser browser;
- private DriverSetting driver;
- private boolean headlessMode;
- private String hubUrl;
- private Map params;
- private PlaybackSetting playback;
- private RemoteSetting remote;
- private String url;
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:10 PM
- */
- public ApplicationSetting () {
- this.params = new HashMap <> ();
- this.browser = AvailableBrowser.CHROME;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @return the browser
- */
- public AvailableBrowser getBrowser () {
- return this.browser;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @return driver setting
- */
- public DriverSetting getDriver () {
- return this.driver;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 5:01:07 PM
- * @return the hubUrl
- */
- public String getHubUrl () {
- return this.hubUrl;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @return the params
- */
- public Map getParams () {
- return this.params;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:35 PM
- * @return the playback
- */
- public PlaybackSetting getPlayback () {
- return this.playback;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return remote
- */
- public RemoteSetting getRemote () {
- return this.remote;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @return the url
- */
- public String getUrl () {
- return this.url;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @return the headlessMode
- */
- public boolean isHeadlessMode () {
- return this.headlessMode;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @param browser
- * the browser to set
- */
- public void setBrowser (final AvailableBrowser browser) {
- this.browser = browser;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @param driver
- */
- public void setDriver (final DriverSetting driver) {
- this.driver = driver;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @param headlessMode
- * the headlessMode to set
- */
- public void setHeadlessMode (final boolean headlessMode) {
- this.headlessMode = headlessMode;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 5:01:07 PM
- * @param hubUrl
- * the hubUrl to set
- */
- public void setHubUrl (final String hubUrl) {
- this.hubUrl = hubUrl;
- }
-
- /**
- * @author wasiqb
- * @since Apr 8, 2019 11:22:53 PM
- * @param params
- * the params to set
- */
- public void setParams (final Map params) {
- this.params = params;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:35 PM
- * @param playback
- * the playback to set
- */
- public void setPlayback (final PlaybackSetting playback) {
- this.playback = playback;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param remote
- */
- public void setRemote (final RemoteSetting remote) {
- this.remote = remote;
- }
-
- /**
- * @author wasiqb
- * @since Apr 7, 2019 5:12:41 PM
- * @param url
- * the url to set
- */
- public void setUrl (final String url) {
- this.url = url;
- }
+@Getter
+@Setter
+public class ApplicationSetting extends BasePojo {
+ private AvailableBrowser browser;
+ private DriverSetting driver;
+ private boolean headlessMode;
+ private String hubUrl;
+ private Map params;
+ private PlaybackSetting playback;
+ private RemoteSetting remote;
+ private String url;
+
+ /**
+ * @author wasiqb
+ * @since Apr 7, 2019 5:12:10 PM
+ */
+ public ApplicationSetting () {
+ this.params = new HashMap<> ();
+ this.browser = AvailableBrowser.CHROME;
+ this.driver = new DriverSetting ();
+ this.playback = new PlaybackSetting ();
+ this.headlessMode = false;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ConfigUtil.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ConfigUtil.java
index 8a19624..0264edf 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ConfigUtil.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ConfigUtil.java
@@ -24,18 +24,18 @@
* @since Aug 9, 2018 8:23:23 PM
*/
public final class ConfigUtil {
- /**
- * @author Wasiq Bhamla
- * @since Aug 9, 2018 8:39:04 PM
- * @return setting
- */
- public static ApplicationSetting appSetting () {
- return settings ().withKey (COTEAFS_CONFIG_KEY)
- .withDefault (COTEAFS_CONFIG_DEFAULT_FILE)
- .load (ApplicationSetting.class);
- }
+ /**
+ * @author Wasiq Bhamla
+ * @since Aug 9, 2018 8:39:04 PM
+ * @return setting
+ */
+ public static ApplicationSetting appSetting () {
+ return settings ().withKey (COTEAFS_CONFIG_KEY)
+ .withDefault (COTEAFS_CONFIG_DEFAULT_FILE)
+ .load (ApplicationSetting.class);
+ }
- private ConfigUtil () {
- // Remove default constructor since class is static util class.
- }
+ private ConfigUtil () {
+ // Remove default constructor since class is static util class.
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DataCategory.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/DataCategory.java
deleted file mode 100644
index 84eaf91..0000000
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DataCategory.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017 - 2020, Wasiq Bhamla.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.github.wasiqb.coteafs.selenium.config;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author wasiqb
- * @since Sep 10, 2018 5:47:31 PM
- */
-public class DataCategory {
- private Map datas;
- private String name;
-
- /**
- * @author wasiqb
- * @since Sep 13, 2018 1:58:45 PM
- */
- public DataCategory () {
- this.datas = new HashMap <> ();
- }
-
- /**
- * @author wasiqb
- * @since Sep 13, 2018 2:03:20 PM
- * @param dataName
- * name
- * @return data
- */
- public Object getData (final String dataName) {
- return this.datas.get (dataName);
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:49:26 PM
- * @return the dataList
- */
- public Map getDatas () {
- return this.datas;
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:49:26 PM
- * @return the name
- */
- public String getName () {
- return this.name;
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:49:26 PM
- * @param dataList
- * the dataList to set
- */
- public void setDatas (final Map dataList) {
- this.datas = dataList;
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:49:26 PM
- * @param name
- * the name to set
- */
- public void setName (final String name) {
- this.name = name;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DataSet.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/DataSet.java
deleted file mode 100644
index 6be4fb4..0000000
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DataSet.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2017 - 2020, Wasiq Bhamla.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.github.wasiqb.coteafs.selenium.config;
-
-/**
- * @author wasiqb
- * @since Sep 10, 2018 5:48:30 PM
- */
-public class DataSet {
- private String name;
- private Object value;
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:48:55 PM
- * @return the name
- */
- public String getName () {
- return this.name;
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:48:55 PM
- * @return the value
- */
- public Object getValue () {
- return this.value;
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:48:55 PM
- * @param name
- * the name to set
- */
- public void setName (final String name) {
- this.name = name;
- }
-
- /**
- * @author wasiqb
- * @since Sep 10, 2018 5:48:55 PM
- * @param value
- * the value to set
- */
- public void setValue (final Object value) {
- this.value = value;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DelaySetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/DelaySetting.java
index cb2ff8b..80fb1c7 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DelaySetting.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/DelaySetting.java
@@ -15,241 +15,39 @@
*/
package com.github.wasiqb.coteafs.selenium.config;
+import com.github.wasiqb.coteafs.config.util.BasePojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since Apr 8, 2018 2:48:55 PM
*/
-public class DelaySetting {
- private long afterClick;
- private long afterKeyPress;
- private long afterMouseMove;
- private long beforeClick;
- private long beforeKeyPress;
- private long beforeMouseMove;
- private long explicit;
- private long highlight;
- private long implicit;
- private long pageLoad;
- private long scriptLoad;
-
- /**
- * @author Wasiq Bhamla
- * @since Aug 15, 2018 3:14:37 PM
- */
- public DelaySetting () {
- this.pageLoad = 60;
- this.scriptLoad = 60;
- this.implicit = 1;
- this.explicit = 10;
- this.highlight = 200;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:53:44 PM
- * @return the afterClick
- */
- public long getAfterClick () {
- return this.afterClick;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the afterMouseMove
- */
- public long getAfterMouseMove () {
- return this.afterMouseMove;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the afterKeyPress
- */
- public long getAfterTyping () {
- return this.afterKeyPress;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:53:44 PM
- * @return the beforeClick
- */
- public long getBeforeClick () {
- return this.beforeClick;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the beforeMouseMove
- */
- public long getBeforeMouseMove () {
- return this.beforeMouseMove;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the beforeKeyPress
- */
- public long getBeforeTyping () {
- return this.beforeKeyPress;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the explicit
- */
- public long getExplicit () {
- return this.explicit;
- }
-
- /**
- * @author wasiqb
- * @since Aug 31, 2018 10:15:33 PM
- * @return the highlight
- */
- public long getHighlight () {
- return this.highlight;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the implicit
- */
- public long getImplicit () {
- return this.implicit;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @return the pageLoad
- */
- public long getPageLoad () {
- return this.pageLoad;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:56:52 PM
- * @return the scriptLoad
- */
- public long getScriptLoad () {
- return this.scriptLoad;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:53:44 PM
- * @param afterClick
- * the afterClick to set
- */
- public void setAfterClick (final long afterClick) {
- this.afterClick = afterClick;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param afterKeyPress
- * the afterKeyPress to set
- */
- public void setAfterKeyPress (final long afterKeyPress) {
- this.afterKeyPress = afterKeyPress;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param afterMouseMove
- * the afterMouseMove to set
- */
- public void setAfterMouseMove (final long afterMouseMove) {
- this.afterMouseMove = afterMouseMove;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:53:44 PM
- * @param beforeClick
- * the beforeClick to set
- */
- public void setBeforeClick (final long beforeClick) {
- this.beforeClick = beforeClick;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param beforeKeyPress
- * the beforeKeyPress to set
- */
- public void setBeforeKeyPress (final long beforeKeyPress) {
- this.beforeKeyPress = beforeKeyPress;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param beforeMouseMove
- * the beforeMouseMove to set
- */
- public void setBeforeMouseMove (final long beforeMouseMove) {
- this.beforeMouseMove = beforeMouseMove;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param explicit
- * the explicit to set
- */
- public void setExplicit (final long explicit) {
- this.explicit = explicit;
- }
-
- /**
- * @author wasiqb
- * @since Aug 31, 2018 10:15:33 PM
- * @param highlight
- * the highlight to set
- */
- public void setHighlight (final long highlight) {
- this.highlight = highlight;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param implicit
- * the implicit to set
- */
- public void setImplicit (final long implicit) {
- this.implicit = implicit;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 2:58:50 PM
- * @param pageLoad
- * the pageLoad to set
- */
- public void setPageLoad (final long pageLoad) {
- this.pageLoad = pageLoad;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:56:52 PM
- * @param scriptLoad
- * the scriptLoad to set
- */
- public void setScriptLoad (final long scriptLoad) {
- this.scriptLoad = scriptLoad;
- }
+@Getter
+@Setter
+public class DelaySetting extends BasePojo {
+ private long afterClick;
+ private long afterFrameSwitch;
+ private long afterKeyPress;
+ private long afterMouseMove;
+ private long afterWindowSwitch;
+ private long beforeClick;
+ private long beforeKeyPress;
+ private long beforeMouseMove;
+ private long explicit;
+ private long highlight;
+ private long implicit;
+ private long pageLoad;
+ private long scriptLoad;
+
+ DelaySetting () {
+ this.pageLoad = 60;
+ this.scriptLoad = 60;
+ this.implicit = 1;
+ this.explicit = 30;
+ this.highlight = 200;
+ this.afterFrameSwitch = 500;
+ this.afterWindowSwitch = 500;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DriverSetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/DriverSetting.java
index 03c62e0..0d1133e 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/DriverSetting.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/DriverSetting.java
@@ -15,104 +15,21 @@
*/
package com.github.wasiqb.coteafs.selenium.config;
+import com.github.wasiqb.coteafs.config.util.BasePojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since 03-Aug-2019
*/
-public class DriverSetting {
- private String exeUrl;
- private boolean forceCache;
- private boolean forceDownload;
- private String path;
- private String version;
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @return exe url
- */
- public String getExeUrl () {
- return this.exeUrl;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @return local path
- */
- public String getPath () {
- return this.path;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @return version
- */
- public String getVersion () {
- return this.version;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @return force cache
- */
- public boolean isForceCache () {
- return this.forceCache;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @return force download
- */
- public boolean isForceDownload () {
- return this.forceDownload;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @param exeUrl
- */
- public void setExeUrl (final String exeUrl) {
- this.exeUrl = exeUrl;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @param forceCache
- */
- public void setForceCache (final boolean forceCache) {
- this.forceCache = forceCache;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @param forceDownload
- */
- public void setForceDownload (final boolean forceDownload) {
- this.forceDownload = forceDownload;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @param path
- */
- public void setPath (final String path) {
- this.path = path;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 03-Aug-2019
- * @param version
- */
- public void setVersion (final String version) {
- this.version = version;
- }
+@Getter
+@Setter
+public class DriverSetting extends BasePojo {
+ private String exeUrl;
+ private boolean forceCache;
+ private boolean forceDownload;
+ private String path;
+ private String version;
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/PlaybackSetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/PlaybackSetting.java
index 96080bd..223727c 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/PlaybackSetting.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/PlaybackSetting.java
@@ -15,119 +15,32 @@
*/
package com.github.wasiqb.coteafs.selenium.config;
+import com.github.wasiqb.coteafs.config.util.BasePojo;
import com.github.wasiqb.coteafs.selenium.core.enums.ScreenState;
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since Apr 8, 2018 2:45:29 PM
*/
-public class PlaybackSetting {
- private DelaySetting delays;
- private boolean highlight;
- private ScreenResolution screenResolution;
- private ScreenshotSetting screenshot;
- private ScreenState screenState;
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 28, 2019
- */
- public PlaybackSetting () {
- this.screenResolution = new ScreenResolution ();
- }
-
- /**
- * @return the delays
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public DelaySetting getDelays () {
- return this.delays;
- }
-
- /**
- * @return the screenResolution
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public ScreenResolution getScreenResolution () {
- return this.screenResolution;
- }
-
- /**
- * @return the screenshot
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public ScreenshotSetting getScreenshot () {
- return this.screenshot;
- }
-
- /**
- * @return the screenState
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public ScreenState getScreenState () {
- return this.screenState;
- }
-
- /**
- * @return the highlight
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public boolean isHighlight () {
- return this.highlight;
- }
-
- /**
- * @param delays
- * the delays to set
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public void setDelays (final DelaySetting delays) {
- this.delays = delays;
- }
-
- /**
- * @param highlight
- * the highlight to set
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public void setHighlight (final boolean highlight) {
- this.highlight = highlight;
- }
-
- /**
- * @param screenResolution
- * the screenSize to set
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public void setScreenResolution (final ScreenResolution screenResolution) {
- this.screenResolution = screenResolution;
- }
-
- /**
- * @param screenshot
- * the screenshot to set
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public void setScreenshot (final ScreenshotSetting screenshot) {
- this.screenshot = screenshot;
- }
-
- /**
- * @param screenState
- * the screenState to set
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:00:22 PM
- */
- public void setScreenState (final ScreenState screenState) {
- this.screenState = screenState;
- }
+@Getter
+@Setter
+public class PlaybackSetting extends BasePojo {
+ private DelaySetting delays;
+ private boolean highlight;
+ private RecorderSetting recording;
+ private ScreenResolution screenResolution;
+ private ScreenshotSetting screenshot;
+ private ScreenState screenState;
+
+ PlaybackSetting () {
+ this.screenResolution = new ScreenResolution ();
+ this.delays = new DelaySetting ();
+ this.screenshot = new ScreenshotSetting ();
+ this.screenState = ScreenState.NORMAL;
+ this.highlight = true;
+ this.recording = new RecorderSetting ();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/RecorderSetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/RecorderSetting.java
new file mode 100644
index 0000000..24ada16
--- /dev/null
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/RecorderSetting.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019, Wasiq Bhamla.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.wasiqb.coteafs.selenium.config;
+
+import com.github.wasiqb.coteafs.config.util.BasePojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author Wasiq Bhamla
+ * @since 27-Oct-2019
+ */
+@Getter
+@Setter
+public class RecorderSetting extends BasePojo {
+ private boolean enable;
+ private String path;
+ private String prefix;
+
+ RecorderSetting () {
+ this.enable = false;
+ this.path = "./video";
+ this.prefix = "VID";
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/RemoteSetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/RemoteSetting.java
index 666859d..0947a5f 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/RemoteSetting.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/RemoteSetting.java
@@ -15,180 +15,36 @@
*/
package com.github.wasiqb.coteafs.selenium.config;
-import static org.apache.commons.text.StringSubstitutor.replaceSystemProperties;
-
import java.util.Map;
+import com.github.wasiqb.coteafs.config.util.BasePojo;
import com.github.wasiqb.coteafs.selenium.core.enums.Protocol;
import com.github.wasiqb.coteafs.selenium.core.enums.RemoteSource;
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since 01-Aug-2019
*/
-public class RemoteSetting {
- private static String getSystemPropertyOrConfig (final String value) {
- return value.startsWith ("${") ? replaceSystemProperties (value) : value;
- }
-
- private Map capabilities;
- private Map cloudCapabilities;
- private String password;
- private int port;
- private Protocol protocol;
- private RemoteSource source;
- private String url;
- private String userId;
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- */
- public RemoteSetting () {
- setProtocol (Protocol.HTTP);
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return capabilities
- */
- public Map getCapabilities () {
- return this.capabilities;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return cloud capabilities
- */
- public Map getCloudCapabilities () {
- return this.cloudCapabilities;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return password
- */
- public String getPassword () {
- return getSystemPropertyOrConfig (this.password);
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return port
- */
- public int getPort () {
- return this.port;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return protocol
- */
- public Protocol getProtocol () {
- return this.protocol;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return source
- */
- public RemoteSource getSource () {
- return this.source;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return url
- */
- public String getUrl () {
- return this.url;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @return user id
- */
- public String getUserId () {
- return getSystemPropertyOrConfig (this.userId);
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param capabilities
- */
- public void setCapabilities (final Map capabilities) {
- this.capabilities = capabilities;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param cloudCapabilities
- */
- public void setCloudCapabilities (final Map cloudCapabilities) {
- this.cloudCapabilities = cloudCapabilities;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param password
- */
- public void setPassword (final String password) {
- this.password = password;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param port
- */
- public void setPort (final int port) {
- this.port = port;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param protocol
- */
- public void setProtocol (final Protocol protocol) {
- this.protocol = protocol;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param source
- */
- public void setSource (final RemoteSource source) {
- this.source = source;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param url
- */
- public void setUrl (final String url) {
- this.url = url;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since 01-Aug-2019
- * @param userId
- */
- public void setUserId (final String userId) {
- this.userId = userId;
- }
+@Getter
+@Setter
+public class RemoteSetting extends BasePojo {
+ private Map capabilities;
+ private Map cloudCapabilities;
+ private String password;
+ private int port;
+ private Protocol protocol;
+ private RemoteSource source;
+ private String url;
+ private String userId;
+
+ /**
+ * @author Wasiq Bhamla
+ * @since 01-Aug-2019
+ */
+ public RemoteSetting () {
+ setProtocol (Protocol.HTTP);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenResolution.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenResolution.java
index d77e4fc..dc2cf49 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenResolution.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenResolution.java
@@ -15,63 +15,34 @@
*/
package com.github.wasiqb.coteafs.selenium.config;
+import static java.lang.String.format;
+
+import com.github.wasiqb.coteafs.config.util.BasePojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since 28 Apr 2019
*/
-public class ScreenResolution {
- private int height;
- private int width;
-
- /**
- * @author Wasiq Bhamla
- * @since 28 Apr 2019
- */
- public ScreenResolution () {
- this.width = 1280;
- this.height = 768;
- }
-
- /**
- * @author Wasiq Bhamla
- * @return height
- * @since 28 Apr 2019
- */
- public int getHeight () {
- return this.height;
- }
-
- /**
- * @author Wasiq Bhamla
- * @return width
- * @since 28 Apr 2019
- */
- public int getWidth () {
- return this.width;
- }
-
- /**
- * @author Wasiq Bhamla
- * @param height
- * height
- * @since 28 Apr 2019
- */
- public void setHeight (final int height) {
- this.height = height;
- }
+@Getter
+@Setter
+public class ScreenResolution extends BasePojo {
+ private int height;
+ private int width;
- /**
- * @author Wasiq Bhamla
- * @param width
- * width
- * @since 28 Apr 2019
- */
- public void setWidth (final int width) {
- this.width = width;
- }
+ /**
+ * @author Wasiq Bhamla
+ * @since 28 Apr 2019
+ */
+ public ScreenResolution () {
+ this.width = 1366;
+ this.height = 1024;
+ }
- @Override
- public String toString () {
- return String.format ("ScreenResolution{height=%d, width=%d}", this.height, this.width);
- }
+ @Override
+ public String toString () {
+ return format ("%dx%d", this.width, this.height);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenshotSetting.java b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenshotSetting.java
index 8e024d0..ca4949e 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenshotSetting.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/config/ScreenshotSetting.java
@@ -15,89 +15,29 @@
*/
package com.github.wasiqb.coteafs.selenium.config;
+import com.github.wasiqb.coteafs.config.util.BasePojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
/**
* @author Wasiq Bhamla
* @since Apr 8, 2018 3:00:06 PM
*/
-public class ScreenshotSetting {
- private boolean captureOnError;
- private String extension;
- private String path;
- private String prefix;
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:58:36 PM
- * @return the extension
- */
- public String getExtension () {
- return this.extension;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:16 PM
- * @return the path
- */
- public String getPath () {
- return this.path;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:16 PM
- * @return the prefix
- */
- public String getPrefix () {
- return this.prefix;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:15 PM
- * @return the captureOnError
- */
- public boolean isCaptureOnError () {
- return this.captureOnError;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:16 PM
- * @param captureOnError
- * the captureOnError to set
- */
- public void setCaptureOnError (final boolean captureOnError) {
- this.captureOnError = captureOnError;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since May 1, 2018 4:58:36 PM
- * @param extension
- * the extension to set
- */
- public void setExtension (final String extension) {
- this.extension = extension;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:16 PM
- * @param path
- * the path to set
- */
- public void setPath (final String path) {
- this.path = path;
- }
-
- /**
- * @author Wasiq Bhamla
- * @since Apr 8, 2018 3:01:16 PM
- * @param prefix
- * the prefix to set
- */
- public void setPrefix (final String prefix) {
- this.prefix = prefix;
- }
+@Getter
+@Setter
+public class ScreenshotSetting extends BasePojo {
+ private boolean captureAll;
+ private boolean captureOnError;
+ private String extension;
+ private String path;
+ private String prefix;
+
+ ScreenshotSetting () {
+ this.captureOnError = false;
+ this.extension = "jpeg";
+ this.path = "./screenshots";
+ this.prefix = "SCR";
+ this.captureAll = false;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/constants/ConfigKeys.java b/src/main/java/com/github/wasiqb/coteafs/selenium/constants/ConfigKeys.java
index 968cb4f..126ab3a 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/constants/ConfigKeys.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/constants/ConfigKeys.java
@@ -20,20 +20,24 @@
* @since Aug 9, 2018 8:24:45 PM
*/
public interface ConfigKeys {
- /**
- * Browser key.
- */
- String BROWSER = "test.browser";
- /**
- * Config file key.
- */
- String CONFIG = "test.config";
- /**
- * Selenium default config key.
- */
- String COTEAFS_CONFIG_DEFAULT_FILE = "/selenium-config.yaml";
- /**
- * Selenium config key.
- */
- String COTEAFS_CONFIG_KEY = "coteafs.selenium.config";
+ /**
+ * Browser key.
+ */
+ String BROWSER = "test.browser";
+ /**
+ * Config file key.
+ */
+ String CONFIG = "test.config";
+ /**
+ * Selenium default config key.
+ */
+ String COTEAFS_CONFIG_DEFAULT_FILE = "selenium-config.yaml";
+ /**
+ * Selenium config key.
+ */
+ String COTEAFS_CONFIG_KEY = "coteafs.selenium.config";
+ /**
+ * Ignore package.
+ */
+ String FILTER_PKG = "com.github.wasiqb";
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/constants/OS.java b/src/main/java/com/github/wasiqb/coteafs/selenium/constants/OS.java
index 13d14b9..3cd8015 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/constants/OS.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/constants/OS.java
@@ -15,6 +15,9 @@
*/
package com.github.wasiqb.coteafs.selenium.constants;
+import static com.github.wasiqb.coteafs.selenium.core.enums.PlatformOs.LINUX;
+import static com.github.wasiqb.coteafs.selenium.core.enums.PlatformOs.MAC;
+import static com.github.wasiqb.coteafs.selenium.core.enums.PlatformOs.WINDOWS;
import static java.lang.System.getProperty;
import com.github.wasiqb.coteafs.selenium.core.enums.PlatformOs;
@@ -24,48 +27,54 @@
* @since Aug 10, 2018 2:37:10 PM
*/
public class OS {
- private static final String NAME = getProperty ("os.name").toLowerCase ();
+ private static final String NAME = getProperty ("os.name").toLowerCase ();
- /**
- * @author Wasiq Bhamla
- * @since Aug 10, 2018 2:38:12 PM
- * @return is Mac
- */
- public static boolean isMac () {
- return NAME.contains ("mac");
- }
+ /**
+ * @return is Mac
+ * @author Wasiq Bhamla
+ * @since Aug 10, 2018 2:38:12 PM
+ */
+ public static boolean isMac () {
+ return NAME.contains ("mac");
+ }
- /**
- * @author Wasiq Bhamla
- * @since Aug 10, 2018 2:38:47 PM
- * @return is unix
- */
- public static boolean isUnix () {
- return NAME.contains ("nix") || NAME.contains ("nux") || NAME.contains ("aix");
- }
+ /**
+ * @return is unix
+ * @author Wasiq Bhamla
+ * @since Aug 10, 2018 2:38:47 PM
+ */
+ public static boolean isUnix () {
+ return NAME.contains ("nix") || NAME.contains ("nux") || NAME.contains ("aix");
+ }
- /**
- * @author Wasiq Bhamla
- * @since Aug 10, 2018 2:38:57 PM
- * @return is win
- */
- public static boolean isWindows () {
- return NAME.contains ("win");
- }
+ /**
+ * @return is win
+ * @author Wasiq Bhamla
+ * @since Aug 10, 2018 2:38:57 PM
+ */
+ public static boolean isWindows () {
+ return NAME.contains ("win");
+ }
- /**
- * @author Wasiq Bhamla
- * @since Aug 10, 2018 2:50:40 PM
- * @return platform
- */
- public static PlatformOs platform () {
- if (isWindows ()) return PlatformOs.WINDOWS;
- if (isMac ()) return PlatformOs.MAC;
- if (isUnix ()) return PlatformOs.LINUX;
- return null;
- }
+ /**
+ * @return platform
+ * @author Wasiq Bhamla
+ * @since Aug 10, 2018 2:50:40 PM
+ */
+ public static PlatformOs platform () {
+ if (isWindows ()) {
+ return WINDOWS;
+ }
+ if (isMac ()) {
+ return MAC;
+ }
+ if (isUnix ()) {
+ return LINUX;
+ }
+ return null;
+ }
- private OS () {
- // Util class.
- }
+ private OS () {
+ // Util class.
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/Browser.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/Browser.java
index 5f68055..6bc3aea 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/Browser.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/Browser.java
@@ -18,6 +18,9 @@
import static com.github.wasiqb.coteafs.error.util.ErrorUtil.fail;
import static com.github.wasiqb.coteafs.selenium.config.ConfigUtil.appSetting;
import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.BROWSER;
+import static com.github.wasiqb.coteafs.selenium.core.base.driver.ParallelSession.close;
+import static com.github.wasiqb.coteafs.selenium.core.base.driver.ParallelSession.getSession;
+import static com.github.wasiqb.coteafs.selenium.core.base.driver.ParallelSession.setSession;
import static com.github.wasiqb.coteafs.selenium.core.enums.Platform.DESKTOP;
import static io.github.bonigarcia.wdm.WebDriverManager.chromedriver;
import static io.github.bonigarcia.wdm.WebDriverManager.edgedriver;
@@ -33,8 +36,18 @@
import java.net.URL;
import java.util.Map;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import com.github.wasiqb.coteafs.logger.Loggy;
+import com.github.wasiqb.coteafs.selenium.config.DriverSetting;
+import com.github.wasiqb.coteafs.selenium.config.RemoteSetting;
+import com.github.wasiqb.coteafs.selenium.constants.OS;
+import com.github.wasiqb.coteafs.selenium.core.base.driver.AbstractDriver;
+import com.github.wasiqb.coteafs.selenium.core.driver.IWebDriver;
+import com.github.wasiqb.coteafs.selenium.core.enums.ApplicationType;
+import com.github.wasiqb.coteafs.selenium.core.enums.AvailableBrowser;
+import com.github.wasiqb.coteafs.selenium.core.enums.RemoteSource;
+import com.github.wasiqb.coteafs.selenium.error.DriverNotSetupError;
+import com.github.wasiqb.coteafs.selenium.listeners.DriverListner;
+import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
@@ -56,235 +69,245 @@
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.testng.Assert;
-import com.github.wasiqb.coteafs.selenium.config.DriverSetting;
-import com.github.wasiqb.coteafs.selenium.config.RemoteSetting;
-import com.github.wasiqb.coteafs.selenium.constants.OS;
-import com.github.wasiqb.coteafs.selenium.core.base.driver.AbstractDriver;
-import com.github.wasiqb.coteafs.selenium.core.driver.IWebDriver;
-import com.github.wasiqb.coteafs.selenium.core.enums.ApplicationType;
-import com.github.wasiqb.coteafs.selenium.core.enums.AvailableBrowser;
-import com.github.wasiqb.coteafs.selenium.core.enums.RemoteSource;
-import com.github.wasiqb.coteafs.selenium.error.DriverNotSetupError;
-import com.github.wasiqb.coteafs.selenium.listeners.DriverListner;
-
-import io.github.bonigarcia.wdm.WebDriverManager;
-
/**
* @author Wasiq Bhamla
* @since Aug 15, 2018 2:11:13 PM
*/
@SuppressWarnings ("unchecked")
-public class Browser extends AbstractDriver implements IWebDriver {
- private static final Logger LOG = LogManager.getLogger (Browser.class);
+public class Browser extends AbstractDriver implements IWebDriver {
+ private static final Loggy LOG = Loggy.init ();
+
+ private static WebDriver createRemoteSession (final RemoteSetting remoteSetting, final MutableCapabilities caps) {
+ LOG.i ("Creating remote session...");
+ final StringBuilder urlBuilder = new StringBuilder (remoteSetting.getProtocol ()
+ .getPrefix ());
+ final String url = remoteSetting.getUrl ();
+ if (remoteSetting.getSource () != RemoteSource.GRID) {
+ final String user = remoteSetting.getUserId ();
+ final String pass = remoteSetting.getPassword ();
+ if (isNotEmpty (user)) {
+ urlBuilder.append (user)
+ .append (":")
+ .append (requireNonNull (pass, "Cloud Password cannot be empty."))
+ .append ("@");
+ }
+ }
+ urlBuilder.append (url);
+ final int port = remoteSetting.getPort ();
+ if (port > 0) {
+ urlBuilder.append (":")
+ .append (port);
+ }
+ urlBuilder.append ("/wd/hub");
+ try {
+ final URL remoteUrl = new URL (urlBuilder.toString ());
+ return new RemoteWebDriver (remoteUrl, caps);
+ } catch (final MalformedURLException e) {
+ LOG.e ("Error occurred while creating remote session: ", e);
+ }
+ return null;
+ }
- private static WebDriver createRemoteSession (final RemoteSetting remoteSetting,
- final MutableCapabilities caps) {
- LOG.info ("Creating remote session...");
- final StringBuilder urlBuilder = new StringBuilder (remoteSetting.getProtocol ()
- .getPrefix ());
- final String url = remoteSetting.getUrl ();
- if (remoteSetting.getSource () != RemoteSource.GRID) {
- final String user = remoteSetting.getUserId ();
- final String pass = remoteSetting.getPassword ();
- if (isNotEmpty (user)) {
- urlBuilder.append (user)
- .append (":")
- .append (requireNonNull (pass, "Cloud Password cannot be empty."))
- .append ("@");
- }
- }
- urlBuilder.append (url);
- final int port = remoteSetting.getPort ();
- if (port > 0) {
- urlBuilder.append (":")
- .append (port);
- }
- urlBuilder.append ("/wd/hub");
- try {
- final URL remoteUrl = new URL (urlBuilder.toString ());
- return new RemoteWebDriver (remoteUrl, caps);
- }
- catch (final MalformedURLException e) {
- LOG.error ("Error occurred while creating remote session: ", e);
- }
- return null;
- }
+ private static WebDriver setupChromeDriver () throws MalformedURLException {
+ LOG.i ("Setting up Chrome driver...");
+ setupDriver (chromedriver ());
+ final ChromeOptions chromeOptions = new ChromeOptions ();
+ chromeOptions.addArguments ("--dns-prefetch-disable");
+ if (appSetting ().isHeadlessMode ()) {
+ chromeOptions.addArguments ("--headless");
+ }
+ chromeOptions.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);
+ final ChromeDriverService chromeService = ChromeDriverService.createDefaultService ();
+ return new ChromeDriver (chromeService, chromeOptions);
+ }
- private static WebDriver setupChromeDriver () throws MalformedURLException {
- LOG.info ("Setting up Chrome driver...");
- setupDriver (chromedriver ());
- final ChromeOptions chromeOptions = new ChromeOptions ();
- chromeOptions.addArguments ("--dns-prefetch-disable");
- if (appSetting ().isHeadlessMode ()) {
- chromeOptions.addArguments ("--headless");
- }
- chromeOptions.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);
- final ChromeDriverService chromeService = ChromeDriverService.createDefaultService ();
- return new ChromeDriver (chromeService, chromeOptions);
- }
+ private static void setupCloud (final RemoteSetting remoteSetting, final DesiredCapabilities caps,
+ final String source) {
+ final Map capabilities = remoteSetting.getCapabilities ();
+ capabilities.forEach (caps::setCapability);
+ if (isNotEmpty (source)) {
+ caps.setCapability (format ("{0}:options", source), remoteSetting.getCloudCapabilities ());
+ }
+ }
- private static void setupCloud (final RemoteSetting remoteSetting,
- final DesiredCapabilities caps, final String source) {
- final Map capabilities = remoteSetting.getCapabilities ();
- capabilities.forEach (caps::setCapability);
- if (isNotEmpty (source)) {
- caps.setCapability (format ("{0}:options", source),
- remoteSetting.getCloudCapabilities ());
- }
- }
+ private static WebDriver setupDriver (final AvailableBrowser browser) {
+ try {
+ switch (browser) {
+ case CHROME:
+ return setupChromeDriver ();
+ case FIREFOX:
+ return setupFirefoxDriver ();
+ case IE:
+ return setupIeDriver ();
+ case EDGE:
+ return setupEdgeDriver ();
+ case SAFARI:
+ return setupSafariDriver ();
+ case REMOTE:
+ default:
+ return setupRemote ();
+ }
+ } catch (final MalformedURLException e) {
+ LOG.e ("URL is malformed.", e);
+ LOG.c (e);
+ }
+ return null;
+ }
- private static WebDriver setupDriver (final AvailableBrowser browser) {
- try {
- switch (browser) {
- case CHROME:
- return setupChromeDriver ();
- case FIREFOX:
- return setupFirefoxDriver ();
- case IE:
- return setupIeDriver ();
- case EDGE:
- return setupEdgeDriver ();
- case SAFARI:
- return setupSafariDriver ();
- case REMOTE:
- default:
- return setupRemote ();
- }
- }
- catch (final MalformedURLException e) {
- LOG.error ("URL is malformed.", e);
- LOG.catching (e);
- }
- return null;
- }
+ private static void setupDriver (final WebDriverManager manager) throws MalformedURLException {
+ final DriverSetting driver = appSetting ().getDriver ();
+ if (!isNull (driver)) {
+ if (isNotEmpty (driver.getVersion ())) {
+ manager.version (driver.getVersion ());
+ }
+ if (isNotEmpty (driver.getExeUrl ())) {
+ manager.driverRepositoryUrl (new URL (driver.getExeUrl ()));
+ }
+ if (driver.isForceCache ()) {
+ manager.forceCache ();
+ }
+ if (driver.isForceDownload ()) {
+ manager.forceDownload ();
+ }
+ if (isNotEmpty (driver.getPath ())) {
+ manager.targetPath (driver.getPath ());
+ }
+ }
+ manager.setup ();
+ }
- private static void setupDriver (final WebDriverManager manager) throws MalformedURLException {
- final DriverSetting driver = appSetting ().getDriver ();
- if (!isNull (driver)) {
- if (isNotEmpty (driver.getVersion ())) manager.version (driver.getVersion ());
- if (isNotEmpty (driver.getExeUrl ()))
- manager.driverRepositoryUrl (new URL (driver.getExeUrl ()));
- if (driver.isForceCache ()) manager.forceCache ();
- if (driver.isForceDownload ()) manager.forceDownload ();
- if (isNotEmpty (driver.getPath ())) manager.targetPath (driver.getPath ());
- }
- manager.setup ();
- }
+ private static WebDriver setupEdgeDriver () throws MalformedURLException {
+ LOG.i ("Setting up Edge driver...");
+ setupDriver (edgedriver ());
+ final EdgeOptions options = new EdgeOptions ();
+ return new EdgeDriver (options);
+ }
- private static WebDriver setupEdgeDriver () throws MalformedURLException {
- LOG.info ("Setting up Edge driver...");
- setupDriver (edgedriver ());
- final EdgeOptions options = new EdgeOptions ();
- return new EdgeDriver (options);
- }
+ private static WebDriver setupFirefoxDriver () throws MalformedURLException {
+ LOG.i ("Setting up Firefox driver...");
+ setupDriver (firefoxdriver ());
+ final DesiredCapabilities capabilities = new DesiredCapabilities ();
+ final FirefoxOptions options = new FirefoxOptions (capabilities);
+ final GeckoDriverService firefoxService = GeckoDriverService.createDefaultService ();
+ return new FirefoxDriver (firefoxService, options);
+ }
- private static WebDriver setupFirefoxDriver () throws MalformedURLException {
- LOG.info ("Setting up Firefox driver...");
- setupDriver (firefoxdriver ());
- final DesiredCapabilities capabilities = new DesiredCapabilities ();
- final FirefoxOptions options = new FirefoxOptions (capabilities);
- final GeckoDriverService firefoxService = GeckoDriverService.createDefaultService ();
- return new FirefoxDriver (firefoxService, options);
- }
+ private static WebDriver setupIeDriver () throws MalformedURLException {
+ LOG.i ("Setting up Internet Explorer driver...");
+ setupDriver (iedriver ());
+ final InternetExplorerOptions ieOptions = new InternetExplorerOptions ();
+ ieOptions.destructivelyEnsureCleanSession ();
+ ieOptions.setCapability ("requireWindowFocus", true);
+ ieOptions.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);
+ final InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService ();
+ if (!OS.isWindows ()) {
+ Assert.fail ("IE is not supported.");
+ }
+ if (appSetting ().isHeadlessMode ()) {
+ LOG.w ("IE does not support headless mode. Hence, ignoring the same...");
+ }
+ return new InternetExplorerDriver (ieService, ieOptions);
+ }
- private static WebDriver setupIeDriver () throws MalformedURLException {
- LOG.info ("Setting up Internet Explorer driver...");
- setupDriver (iedriver ());
- final InternetExplorerOptions ieOptions = new InternetExplorerOptions ();
- ieOptions.destructivelyEnsureCleanSession ();
- ieOptions.setCapability ("requireWindowFocus", true);
- ieOptions.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);
- final InternetExplorerDriverService ieService = InternetExplorerDriverService
- .createDefaultService ();
- if (!OS.isWindows ()) {
- Assert.fail ("IE is not supported.");
- }
- if (appSetting ().isHeadlessMode ()) {
- LOG.warn ("IE does not support headless mode. Hence, ignoring the same...");
- }
- return new InternetExplorerDriver (ieService, ieOptions);
- }
+ private static WebDriver setupRemote () {
+ LOG.i ("Setting up Remote driver...");
+ final RemoteSetting remoteSetting = appSetting ().getRemote ();
+ final RemoteSource source = remoteSetting.getSource ();
+ final DesiredCapabilities caps = new DesiredCapabilities ();
+ switch (source) {
+ case SAUCELABS:
+ setupCloud (remoteSetting, caps, "sauce");
+ break;
+ case BROWSERSTACK:
+ setupCloud (remoteSetting, caps, "bstack");
+ break;
+ case GRID:
+ default:
+ setupCloud (remoteSetting, caps, null);
+ break;
+ }
+ return createRemoteSession (remoteSetting, caps);
+ }
- private static WebDriver setupRemote () {
- LOG.info ("Setting up Remote driver...");
- final RemoteSetting remoteSetting = appSetting ().getRemote ();
- final RemoteSource source = remoteSetting.getSource ();
- final DesiredCapabilities caps = new DesiredCapabilities ();
- switch (source) {
- case SAUCELABS:
- setupCloud (remoteSetting, caps, "sauce");
- break;
- case BROWSERSTACK:
- setupCloud (remoteSetting, caps, "bstack");
- break;
- case GRID:
- default:
- setupCloud (remoteSetting, caps, null);
- break;
- }
- return createRemoteSession (remoteSetting, caps);
- }
+ private static WebDriver setupSafariDriver () {
+ LOG.i ("Setting up Safari driver...");
+ if (!OS.isMac ()) {
+ Assert.fail ("Safari is not supported.");
+ }
+ if (appSetting ().isHeadlessMode ()) {
+ LOG.w ("Safari does not support Headless mode. Hence, ignoring the same...");
+ }
+ final SafariOptions options = new SafariOptions ();
+ return new SafariDriver (options);
+ }
- private static WebDriver setupSafariDriver () {
- LOG.info ("Setting up Safari driver...");
- if (!OS.isMac ()) {
- Assert.fail ("Safari is not supported.");
- }
- if (appSetting ().isHeadlessMode ()) {
- LOG.warn ("Safari does not support Headless mode. Hence, ignoring the same...");
- }
- final SafariOptions options = new SafariOptions ();
- return new SafariDriver (options);
- }
+ private AvailableBrowser availableBrowser;
+ private String browserName;
+ private final DriverListner listener;
- private String browserName;
- private final DriverListner listener;
+ /**
+ * @author Wasiq Bhamla
+ * @since 06-Jun-2019
+ */
+ public Browser () {
+ super (DESKTOP);
+ this.listener = new DriverListner ();
+ }
- /**
- * @author Wasiq Bhamla
- * @since 06-Jun-2019
- */
- public Browser () {
- super (DESKTOP);
- this.listener = new DriverListner ();
- }
+ @Override
+ public ApplicationType getApplicationType () {
+ return ApplicationType.WEB;
+ }
- @Override
- public ApplicationType getApplicationType () {
- return ApplicationType.WEB;
- }
+ @Override
+ public EventFiringWebDriver getDriver () {
+ return getSession ().getDriver ();
+ }
- @Override
- public BrowserActions perform () {
- return new BrowserActions (getDriver ());
- }
+ @Override
+ public BrowserActions perform () {
+ return new BrowserActions (getDriver ());
+ }
- @Override
- public void setBrowserUnderTest (final String browser) {
- this.browserName = browser;
- }
+ @Override
+ public void setBrowserUnderTest (final String browser) {
+ this.browserName = browser;
+ }
- @Override
- public void start () {
- LOG.info ("Starting the browser...");
- String target = this.browserName;
- if (target == null) {
- target = getProperty (BROWSER, appSetting ().getBrowser ()
- .name ());
- }
- final AvailableBrowser browser = AvailableBrowser.valueOf (target.toUpperCase ());
- final WebDriver driver = setupDriver (browser);
- if (isNull (driver)) fail (DriverNotSetupError.class, "Driver was not setup properly.");
- final EventFiringWebDriver wd = new EventFiringWebDriver (driver);
- wd.register (this.listener);
- driver (wd);
- setupDriverOptions ();
- }
+ @Override
+ public void start () {
+ LOG.i ("Starting the browser...");
+ String target = this.browserName;
+ if (target == null) {
+ target = getProperty (BROWSER, appSetting ().getBrowser ()
+ .name ());
+ }
+ this.availableBrowser = AvailableBrowser.valueOf (target.toUpperCase ());
+ final WebDriver driver = setupDriver (this.availableBrowser);
+ if (isNull (driver)) {
+ fail (DriverNotSetupError.class, "Driver was not setup properly.");
+ }
+ final EventFiringWebDriver wd = new EventFiringWebDriver (driver);
+ wd.register (this.listener);
+ setSession (new BrowserSession (wd));
+ setupDriverOptions ();
+ if (this.availableBrowser != AvailableBrowser.REMOTE) {
+ perform ().startRecording ();
+ } else {
+ LOG.w ("Video recording is disabled for Remote execution...");
+ }
+ }
- @Override
- public void stop () {
- LOG.info ("Stopping the browser...");
- getDriver ().quit ();
- driver (null);
- }
+ @Override
+ public void stop () {
+ LOG.i ("Stopping the browser...");
+ if (this.availableBrowser != AvailableBrowser.REMOTE) {
+ perform ().stopRecording ();
+ } else {
+ LOG.w ("Video recording is disabled for Remote execution...");
+ }
+ getDriver ().unregister (this.listener);
+ getSession ().close ();
+ close ();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserActions.java
index c1415c0..e5d7bcc 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserActions.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserActions.java
@@ -15,68 +15,84 @@
*/
package com.github.wasiqb.coteafs.selenium.core;
-import java.util.Set;
+import static com.github.wasiqb.coteafs.selenium.config.ConfigUtil.appSetting;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.support.events.EventFiringWebDriver;
+import java.util.Set;
+import com.github.wasiqb.coteafs.selenium.config.DelaySetting;
import com.github.wasiqb.coteafs.selenium.core.base.driver.WebDriverAction;
import com.github.wasiqb.coteafs.selenium.core.driver.IWebFrame;
import com.github.wasiqb.coteafs.selenium.core.driver.IWebWindow;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.events.EventFiringWebDriver;
/**
* @author Wasiq Bhamla
* @since Aug 18, 2018 4:41:56 PM
*/
-public class BrowserActions extends WebDriverAction
- implements IWebFrame, IWebWindow {
- /**
- * @author Wasiq Bhamla
- * @since 02-Jun-2019
- * @param driver
- * driver
- */
- BrowserActions (final EventFiringWebDriver driver) {
- super (driver);
- }
+public class BrowserActions extends WebDriverAction implements IWebFrame, IWebWindow {
+ private final DelaySetting delaySetting;
+
+ /**
+ * @param driver driver
+ * @author Wasiq Bhamla
+ * @since 02-Jun-2019
+ */
+ BrowserActions (final EventFiringWebDriver driver) {
+ super (driver);
+ this.delaySetting = appSetting ().getPlayback ()
+ .getDelays ();
+ }
- @Override
- public void switchFrame () {
- switchFrame (0);
- }
+ @Override
+ public void switchFrame () {
+ switchFrame (0);
+ }
- @Override
- public void switchFrame (final int index) {
- perform (d -> d.switchTo ()
- .frame (index));
- }
+ @Override
+ public void switchFrame (final int index) {
+ perform (d -> {
+ d.switchTo ()
+ .frame (index);
+ pause (this.delaySetting.getAfterFrameSwitch ());
+ });
+ }
- @Override
- public void switchFrame (final String nameOrId) {
- perform (d -> d.switchTo ()
- .frame (nameOrId));
- }
+ @Override
+ public void switchFrame (final String nameOrId) {
+ perform (d -> {
+ d.switchTo ()
+ .frame (nameOrId);
+ pause (this.delaySetting.getAfterFrameSwitch ());
+ });
+ }
- @Override
- public void switchWindow () {
- perform (d -> d.switchTo ()
- .defaultContent ());
- }
+ @Override
+ public void switchWindow () {
+ perform (d -> {
+ d.switchTo ()
+ .defaultContent ();
+ pause (this.delaySetting.getAfterWindowSwitch ());
+ });
+ }
- @Override
- public void switchWindow (final String title) {
- perform (d -> {
- final String currentHandle = d.getWindowHandle ();
- final Set wins = d.getWindowHandles ();
- for (final String win : wins) {
- if (currentHandle.equals (win)) {
- continue;
- }
- final WebDriver w = d.switchTo ()
- .window (win);
- if (w.getTitle ()
- .contains (title)) return;
- }
- });
- }
+ @Override
+ public void switchWindow (final String title) {
+ perform (d -> {
+ final String currentHandle = d.getWindowHandle ();
+ final Set wins = d.getWindowHandles ();
+ for (final String win : wins) {
+ if (currentHandle.equals (win)) {
+ continue;
+ }
+ final WebDriver w = d.switchTo ()
+ .window (win);
+ if (w.getTitle ()
+ .contains (title)) {
+ return;
+ }
+ }
+ pause (this.delaySetting.getAfterWindowSwitch ());
+ });
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserPage.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserPage.java
index cd5b055..53989bb 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserPage.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserPage.java
@@ -15,94 +15,109 @@
*/
package com.github.wasiqb.coteafs.selenium.core;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.events.EventFiringWebDriver;
+import static com.github.wasiqb.coteafs.error.util.ErrorUtil.handleError;
+import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.FILTER_PKG;
+import com.github.wasiqb.coteafs.logger.Loggy;
import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions;
import com.github.wasiqb.coteafs.selenium.core.element.ISelectboxActions;
import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions;
import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy;
import com.github.wasiqb.coteafs.selenium.core.page.IPage;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.events.EventFiringWebDriver;
/**
* @author Wasiq Bhamla
* @since Aug 19, 2018 4:15:31 PM
*/
@SuppressWarnings ("unchecked")
-public class BrowserPage implements IPage {
- private final Browser browser;
-
- /**
- * @author Wasiq Bhamla
- * @since 02-Jun-2019
- */
- public BrowserPage () {
- this.browser = new Browser ();
- }
-
- @Override
- public IMouseActions onClickable (final By locator) {
- return new WebElementAction (onDriver (), locator);
- }
-
- @Override
- public IMouseActions onClickable (final By locator, final WaitStrategy strategy) {
- return new WebElementAction (onDriver (), locator, strategy);
- }
-
- @Override
- public IMouseActions onClickable (final WebElement element) {
- return new WebElementAction (onDriver (), element);
- }
-
- @Override
- public IMouseActions onClickable (final WebElement element, final WaitStrategy strategy) {
- return new WebElementAction (onDriver (), element, strategy);
- }
-
- @Override
- public BrowserActions onDriver () {
- return new BrowserActions (this.browser.getDriver ());
- }
-
- @Override
- public ISelectboxActions onDropdown (final By locator) {
- return new WebElementAction (onDriver (), locator);
- }
-
- @Override
- public ISelectboxActions onDropdown (final By locator, final WaitStrategy strategy) {
- return new WebElementAction (onDriver (), locator, strategy);
- }
-
- @Override
- public ISelectboxActions onDropdown (final WebElement element) {
- return new WebElementAction (onDriver (), element);
- }
-
- @Override
- public ISelectboxActions onDropdown (final WebElement element, final WaitStrategy strategy) {
- return new WebElementAction (onDriver (), element, strategy);
- }
-
- @Override
- public ITextboxActions onTextbox (final By locator) {
- return new WebElementAction (onDriver (), locator);
- }
-
- @Override
- public ITextboxActions onTextbox (final By locator, final WaitStrategy strategy) {
- return new WebElementAction (onDriver (), locator, strategy);
- }
-
- @Override
- public ITextboxActions onTextbox (final WebElement element) {
- return new WebElementAction (onDriver (), element);
- }
-
- @Override
- public ITextboxActions onTextbox (final WebElement element, final WaitStrategy strategy) {
- return new WebElementAction (onDriver (), element, strategy);
- }
+public class BrowserPage implements IPage {
+ private static final Loggy LOG = Loggy.init ();
+ private final Browser browser;
+
+ /**
+ * @author Wasiq Bhamla
+ * @since 02-Jun-2019
+ */
+ public BrowserPage () {
+ this.browser = new Browser ();
+ }
+
+ @Override
+ public > T nextPage (final Class pageCls) {
+ T page = null;
+ try {
+ page = pageCls.newInstance ();
+ } catch (final InstantiationException | IllegalAccessException e) {
+ handleError (FILTER_PKG, e).forEach (LOG::e);
+ }
+ return page;
+ }
+
+ @Override
+ public IMouseActions onClickable (final By locator, final String name) {
+ return new WebElementAction (onDriver (), locator, name);
+ }
+
+ @Override
+ public IMouseActions onClickable (final By locator, final String name, final WaitStrategy strategy) {
+ return new WebElementAction (onDriver (), locator, name, strategy);
+ }
+
+ @Override
+ public IMouseActions onClickable (final WebElement element, final String name) {
+ return new WebElementAction (onDriver (), element, name);
+ }
+
+ @Override
+ public IMouseActions onClickable (final WebElement element, final String name, final WaitStrategy strategy) {
+ return new WebElementAction (onDriver (), element, name, strategy);
+ }
+
+ @Override
+ public BrowserActions onDriver () {
+ return new BrowserActions (this.browser.getDriver ());
+ }
+
+ @Override
+ public ISelectboxActions onDropdown (final By locator, final String name) {
+ return new WebElementAction (onDriver (), locator, name);
+ }
+
+ @Override
+ public ISelectboxActions onDropdown (final By locator, final String name, final WaitStrategy strategy) {
+ return new WebElementAction (onDriver (), locator, name, strategy);
+ }
+
+ @Override
+ public ISelectboxActions onDropdown (final WebElement element, final String name) {
+ return new WebElementAction (onDriver (), element, name);
+ }
+
+ @Override
+ public ISelectboxActions onDropdown (final WebElement element, final String name, final WaitStrategy strategy) {
+ return new WebElementAction (onDriver (), element, name, strategy);
+ }
+
+ @Override
+ public ITextboxActions onTextbox (final By locator, final String name) {
+ return new WebElementAction (onDriver (), locator, name);
+ }
+
+ @Override
+ public ITextboxActions onTextbox (final By locator, final String name, final WaitStrategy strategy) {
+ return new WebElementAction (onDriver (), locator, name, strategy);
+ }
+
+ @Override
+ public ITextboxActions onTextbox (final WebElement element, final String name) {
+ return new WebElementAction (onDriver (), element, name);
+ }
+
+ @Override
+ public ITextboxActions onTextbox (final WebElement element, final String name, final WaitStrategy strategy) {
+ return new WebElementAction (onDriver (), element, name, strategy);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserSession.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserSession.java
new file mode 100644
index 0000000..2bf3a72
--- /dev/null
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserSession.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019, Wasiq Bhamla.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.wasiqb.coteafs.selenium.core;
+
+import com.github.wasiqb.coteafs.selenium.core.base.driver.DriverSession;
+
+import org.openqa.selenium.support.events.EventFiringWebDriver;
+
+/**
+ * @author Wasiq Bhamla
+ * @since 28-Sep-2019
+ */
+public class BrowserSession extends DriverSession {
+ /**
+ * @author Wasiq Bhamla
+ * @param driver
+ * @since 28-Sep-2019
+ */
+ BrowserSession (final EventFiringWebDriver driver) {
+ super (driver);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserTest.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserTest.java
index 7122c2d..b52909e 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserTest.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserTest.java
@@ -19,9 +19,14 @@
import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.BROWSER;
import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.CONFIG;
import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.COTEAFS_CONFIG_KEY;
+import static com.github.wasiqb.coteafs.selenium.utils.ReportPortalLoggy.log;
import static java.lang.System.setProperty;
import static org.apache.logging.log4j.util.Strings.isNotEmpty;
+import java.io.File;
+
+import com.github.wasiqb.coteafs.selenium.config.ScreenshotSetting;
+import com.github.wasiqb.coteafs.selenium.utils.LogLevel;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
@@ -34,50 +39,54 @@
* @since Sep 13, 2018 9:54:10 PM
*/
public class BrowserTest {
- private Browser browser;
+ private Browser browser;
- /**
- * @author wasiqb
- * @since Sep 13, 2018 9:55:41 PM
- * @param browserName
- * Browser name
- * @param configFile
- */
- @Parameters ({ BROWSER, CONFIG })
- @BeforeTest (alwaysRun = true)
- public void setupTest (@Optional final String browserName, @Optional final String configFile) {
- if (isNotEmpty (configFile)) {
- setProperty (COTEAFS_CONFIG_KEY, configFile);
- }
- this.browser = new Browser ();
- this.browser.setBrowserUnderTest (browserName);
- this.browser.start ();
- }
+ /**
+ * @param browserName Browser name
+ * @param configFile
+ * @author wasiqb
+ * @since Sep 13, 2018 9:55:41 PM
+ */
+ @Parameters ({ BROWSER, CONFIG })
+ @BeforeTest (alwaysRun = true)
+ public void setupTest (@Optional final String browserName, @Optional final String configFile) {
+ if (isNotEmpty (configFile)) {
+ setProperty (COTEAFS_CONFIG_KEY, configFile);
+ }
+ this.browser = new Browser ();
+ this.browser.setBrowserUnderTest (browserName);
+ this.browser.start ();
+ }
- /**
- * @author wasiqb
- * @since Mar 21, 2019 6:46:47 PM
- * @param result
- * test result
- */
- @AfterMethod (alwaysRun = true)
- public void teardownMethod (final ITestResult result) {
- final boolean screenshotOnError = appSetting ().getPlayback ()
- .getScreenshot ()
- .isCaptureOnError ();
- if (screenshotOnError && result.getStatus () == ITestResult.FAILURE
- && !this.browser.isRunning ()) {
- this.browser.perform ()
- .attachScreenshot ();
- }
- }
+ /**
+ * @param result test result
+ * @author wasiqb
+ * @since Mar 21, 2019 6:46:47 PM
+ */
+ @AfterMethod (alwaysRun = true)
+ public void teardownMethod (final ITestResult result) {
+ final ScreenshotSetting screenshotSetting = appSetting ().getPlayback ()
+ .getScreenshot ();
+ final boolean screenshotOnError = screenshotSetting.isCaptureOnError ();
+ final boolean captureAll = screenshotSetting.isCaptureAll ();
+ if (captureAll || screenshotOnError && result.getStatus () == ITestResult.FAILURE && this.browser.isRunning ()) {
+ final File screenshot = this.browser.perform ()
+ .saveScreenshot ();
+ final Throwable cause = result.getThrowable ();
+ if (cause != null) {
+ log (LogLevel.ERROR, screenshot, "Test Failed");
+ } else {
+ log (LogLevel.INFO, screenshot, "Screenshot captured.");
+ }
+ }
+ }
- /**
- * @author wasiqb
- * @since Sep 13, 2018 9:57:12 PM
- */
- @AfterTest (alwaysRun = true)
- public void teardownTest () {
- this.browser.stop ();
- }
+ /**
+ * @author wasiqb
+ * @since Sep 13, 2018 9:57:12 PM
+ */
+ @AfterTest (alwaysRun = true)
+ public void teardownTest () {
+ this.browser.stop ();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/WebElementAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/WebElementAction.java
index 8227bc2..d036362 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/WebElementAction.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/WebElementAction.java
@@ -15,34 +15,32 @@
*/
package com.github.wasiqb.coteafs.selenium.core;
+import com.github.wasiqb.coteafs.selenium.core.base.element.AbstractElementAction;
+import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy;
+
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.events.EventFiringWebDriver;
-import com.github.wasiqb.coteafs.selenium.core.base.element.AbstractElementAction;
-import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy;
-
/**
* @author Wasiq Bhamla
* @since 27-Jul-2019
*/
-public class WebElementAction
- extends AbstractElementAction {
- WebElementAction (final BrowserActions browserAction, final By by) {
- super (browserAction, by);
- }
+class WebElementAction extends AbstractElementAction {
+ WebElementAction (final BrowserActions browserAction, final By by, final String name) {
+ super (browserAction, by, name);
+ }
- WebElementAction (final BrowserActions browserAction, final By by,
- final WaitStrategy strategy) {
- super (browserAction, by, strategy);
- }
+ WebElementAction (final BrowserActions browserAction, final By by, final String name, final WaitStrategy strategy) {
+ super (browserAction, by, name, strategy);
+ }
- WebElementAction (final BrowserActions browserAction, final WebElement element) {
- super (browserAction, element);
- }
+ WebElementAction (final BrowserActions browserAction, final WebElement element, final String name) {
+ super (browserAction, element, name);
+ }
- WebElementAction (final BrowserActions browserAction, final WebElement element,
- final WaitStrategy strategy) {
- super (browserAction, element, strategy);
- }
+ WebElementAction (final BrowserActions browserAction, final WebElement element, final String name,
+ final WaitStrategy strategy) {
+ super (browserAction, element, name, strategy);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriver.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriver.java
index 10cc7b1..e9a9e37 100644
--- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriver.java
+++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriver.java
@@ -21,15 +21,7 @@
import java.util.function.Consumer;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.openqa.selenium.Dimension;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebDriver.Options;
-import org.openqa.selenium.WebDriver.Timeouts;
-import org.openqa.selenium.WebDriver.Window;
-import org.openqa.selenium.remote.RemoteWebDriver;
-
+import com.github.wasiqb.coteafs.logger.Loggy;
import com.github.wasiqb.coteafs.selenium.config.DelaySetting;
import com.github.wasiqb.coteafs.selenium.config.PlaybackSetting;
import com.github.wasiqb.coteafs.selenium.config.ScreenResolution;
@@ -38,85 +30,79 @@
import com.github.wasiqb.coteafs.selenium.core.enums.Platform;
import com.github.wasiqb.coteafs.selenium.core.enums.ScreenState;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.Point;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebDriver.Options;
+import org.openqa.selenium.WebDriver.Timeouts;
+import org.openqa.selenium.WebDriver.Window;
+import org.openqa.selenium.remote.RemoteWebDriver;
+
/**
* @author Wasiq Bhamla
* @param
* @since 26-Jul-2019
*/
-@SuppressWarnings ("unchecked")
-public abstract class AbstractDriver extends PlatformAction
- implements IDriver {
- private static final ThreadLocal