From e101f14c22cc5fee0ae4014fa6f1baa24490cbcf Mon Sep 17 00:00:00 2001 From: Wasiq Bhamla Date: Thu, 5 Dec 2019 19:29:08 +0530 Subject: [PATCH] Released v-3.1.0 (#118) * Develop (#67) * Framework refactored. * Updated config. * Added funding details. * Update issue templates * Issue 55 (#62) * Added annotation @Find and modified login page for new page factory. * Updated page factory annotation. * Updated config for headless mode. * Updated:- Listener to log exceptions correctly. - Added logging to page factory. * Updasted dependencies and fixed dependency breaking changes. * Reverted page factory changes. * Driver and DriverAction interfaces further modularized. * Added support for Selenium WebDriver 4.0-alpha 2 * Updating Readme. * Updated Readme, some work is pending. * Updated Readme and removed unnecessary comments from test. * Updated Readme. * Added iFrame support. * Updated readme as per suggesstion. * Updated for getting first frame. * Released v-2.0.0 * Updated Readme. * Updated CircleCI config to run analysis on each branch. * Release for v-2.1.0-Beta (#81) * Framework refactored. * Updated config. * Added funding details. * Update issue templates * Issue 55 (#62) * Added annotation @Find and modified login page for new page factory. * Updated page factory annotation. * Updated config for headless mode. * Updated:- Listener to log exceptions correctly. - Added logging to page factory. * Updasted dependencies and fixed dependency breaking changes. * Reverted page factory changes. * Driver and DriverAction interfaces further modularized. * Added support for Selenium WebDriver 4.0-alpha 2 * Updating Readme. * Updated Readme, some work is pending. * Updated Readme and removed unnecessary comments from test. * Updated Readme. * Added iFrame support. * Updated readme as per suggesstion. * Updated for getting first frame. * Fixed #77, added wait strategy concept, default will be NONE. * Updated BrowserPage for new method implementation. * Added Safari browser support. * Added OS condition to fail for non-Mac platforms. * Updated Readme (#80) * Released v-2.1.0-beta1. * Released v-2.1.0 * Prepare for Release of v3.0.0 (#102) * Framework refactored. * Updated config. * Added funding details. * Update issue templates * Issue 55 (#62) * Added annotation @Find and modified login page for new page factory. * Updated page factory annotation. * Updated config for headless mode. * Updated:- Listener to log exceptions correctly. - Added logging to page factory. * Updasted dependencies and fixed dependency breaking changes. * Reverted page factory changes. * Driver and DriverAction interfaces further modularized. * Added support for Selenium WebDriver 4.0-alpha 2 * Updating Readme. * Updated Readme, some work is pending. * Updated Readme and removed unnecessary comments from test. * Updated Readme. * Added iFrame support. * Updated readme as per suggesstion. * Updated for getting first frame. * Fixed #77, added wait strategy concept, default will be NONE. * Updated BrowserPage for new method implementation. * Added Safari browser support. * Added OS condition to fail for non-Mac platforms. * Updated Readme (#80) * Fixed #87, added isRunning method to IServiceAction interface. * Fixed #86, added new methods for saveScreenshots. * Fixed #84 by adding new methods for finding on element with wait strategy. (#92) * Fixed #85, updated method find and finds. (#94) * WebDrivermanager version (#95) * Issue 88 (#96) * #88: Refactored the code base and many breaking changes done. * #88: Fixed issue with find and finds method. * #88: Refactoring done for the find method failure. * #88: code formatted with Eclipse. * #13: Added support for BrowserStack. (#97) * #13: Added support for BrowserStack and SauceLabs. Working for BrowserStack. * CircleCI config updated with BrowserStack related tests. * Added talisman ignore file. * Updated Config util to load settings each time it's called. * #93 is fixed, added driver specific settings. (#98) * Readme (#99) * Updated Readme. * Updated talisman ignore file. * Updated readme. * Run config updated. * Selenium Grid support. (#101) * Updated CircleCI config file for Selenium Grid. * Added coteafs-listener for better CI logs debugging. * Added attach workspace setting for Grid execution. * Updated Browser class to run on grid. * Updated Readme. * Updated dependency. * Removed redundand tests. * Released v3.0.0-beta1 * [ci skip] updated readme code snippet. * Release v-3.1.0 preparation (#117) * Framework refactored. * Updated config. * Added funding details. * Update issue templates * Issue 55 (#62) * Added annotation @Find and modified login page for new page factory. * Updated page factory annotation. * Updated config for headless mode. * Updated:- Listener to log exceptions correctly. - Added logging to page factory. * Updasted dependencies and fixed dependency breaking changes. * Reverted page factory changes. * Driver and DriverAction interfaces further modularized. * Added support for Selenium WebDriver 4.0-alpha 2 * Updating Readme. * Updated Readme, some work is pending. * Updated Readme and removed unnecessary comments from test. * Updated Readme. * Added iFrame support. * Updated readme as per suggesstion. * Updated for getting first frame. * Fixed #77, added wait strategy concept, default will be NONE. * Updated BrowserPage for new method implementation. * Added Safari browser support. * Added OS condition to fail for non-Mac platforms. * Updated Readme (#80) * Fixed #87, added isRunning method to IServiceAction interface. * Fixed #86, added new methods for saveScreenshots. * Fixed #84 by adding new methods for finding on element with wait strategy. (#92) * Fixed #85, updated method find and finds. (#94) * WebDrivermanager version (#95) * Issue 88 (#96) * #88: Refactored the code base and many breaking changes done. * #88: Fixed issue with find and finds method. * #88: Refactoring done for the find method failure. * #88: code formatted with Eclipse. * #13: Added support for BrowserStack. (#97) * #13: Added support for BrowserStack and SauceLabs. Working for BrowserStack. * CircleCI config updated with BrowserStack related tests. * Added talisman ignore file. * Updated Config util to load settings each time it's called. * #93 is fixed, added driver specific settings. (#98) * Readme (#99) * Updated Readme. * Updated talisman ignore file. * Updated readme. * Run config updated. * Selenium Grid support. (#101) * Updated CircleCI config file for Selenium Grid. * Added coteafs-listener for better CI logs debugging. * Added attach workspace setting for Grid execution. * Updated Browser class to run on grid. * Updated Readme. * Updated dependency. * Removed redundand tests. * Updated Selenium version to latest stable release. (#108) * Updated outdated coteafs dependencies. (#109) * Updated outdated dependencies of other coteafs modules. Also corrected code style as per checkstyle reporter. * Updated talisman config. * Added new listeners to testng.xml files. * Updated config paths. * Updated grid capabilities for latest chrome. * Issue 100 (#110) * Fixed #100: Added Element alias. * Updated logs for Alert and screen resolution. * Added Session management feature with Parallel support. (#112) * Added session to manage the Driver within Threads. * Corrected logging of alerts. * Updated Page Action base to use current session context. * Fixed checkstyle issue. * Fixes #23: Added page transition support to page classes. (#113) * Fixes #23: Added page transition support to page classes. * Updated for replacing Logger with Loggy. * Fixes #107: Added support for video recording. (#114) * Fixes #107: Added support for video recording. * Changes done as per review comments. * Fixed logging issue for alert. * Fixes #111: Added delay after frame switch and window switch. (#115) * Integration with ReportPortal changes is in progress. (#116) * Integration with ReportPortal changes is in progress. * Updated dependencies to use ReportPortal directly. * Refactoring done. * Updated config file. * Deleted RP config file. * Updated testng file to remove RP listener.. * Fixed sonar issues. * Fixed test failure issue. * Fixed test failure issue for grid and BrowserStack. * Fixed review comments. * Updated README for new changes. * Released v-3.1.0 --- .gitignore | 4 +- .talismanrc | 24 + README.md | 33 +- checkstyle-suppressions.xml | 24 + checkstyle.xml | 170 +++++++ pom.xml | 77 ++- .../selenium/config/ApplicationSetting.java | 195 ++------ .../coteafs/selenium/config/ConfigUtil.java | 26 +- .../coteafs/selenium/config/DataCategory.java | 85 ---- .../coteafs/selenium/config/DataSet.java | 63 --- .../coteafs/selenium/config/DelaySetting.java | 264 ++--------- .../selenium/config/DriverSetting.java | 109 +---- .../selenium/config/PlaybackSetting.java | 131 +----- .../selenium/config/RecorderSetting.java | 39 ++ .../selenium/config/RemoteSetting.java | 190 +------- .../selenium/config/ScreenResolution.java | 77 +-- .../selenium/config/ScreenshotSetting.java | 102 +--- .../selenium/constants/ConfigKeys.java | 36 +- .../wasiqb/coteafs/selenium/constants/OS.java | 87 ++-- .../wasiqb/coteafs/selenium/core/Browser.java | 445 +++++++++--------- .../coteafs/selenium/core/BrowserActions.java | 114 +++-- .../coteafs/selenium/core/BrowserPage.java | 171 ++++--- .../coteafs/selenium/core/BrowserSession.java | 35 ++ .../coteafs/selenium/core/BrowserTest.java | 95 ++-- .../selenium/core/WebElementAction.java | 36 +- .../core/base/driver/AbstractDriver.java | 142 +++--- .../core/base/driver/AlertAction.java | 57 +-- .../core/base/driver/BaseDriverAction.java | 75 +-- .../base/driver/CustomScreenRecorder.java | 135 ++++++ .../core/base/driver/DriverSession.java | 100 ++++ .../core/base/driver/ParallelSession.java | 56 +++ .../core/base/driver/PlatformAction.java | 42 +- .../core/base/driver/ScreenAction.java | 134 ++++-- .../core/base/driver/ScriptAction.java | 44 -- .../core/base/driver/WebDriverAction.java | 74 ++- .../base/element/AbstractElementAction.java | 308 ++++++------ .../core/base/element/BaseElementAction.java | 370 +++++++-------- .../core/base/element/ElementAction.java | 84 ++-- .../core/base/element/FindableAction.java | 62 +-- .../core/base/element/KeyboardAction.java | 44 +- .../core/base/element/VerifyElement.java | 76 +-- .../selenium/core/driver/IAlertAction.java | 30 +- .../coteafs/selenium/core/driver/IDriver.java | 45 +- .../selenium/core/driver/IDriverActions.java | 32 +- .../selenium/core/driver/IPlatformAction.java | 24 +- .../selenium/core/driver/IScreenAction.java | 50 +- .../selenium/core/driver/IScriptAction.java | 21 +- .../selenium/core/driver/IServiceAction.java | 32 +- .../selenium/core/driver/IWaitAction.java | 26 +- .../selenium/core/driver/IWebDriver.java | 15 +- .../core/driver/IWebDriverActions.java | 58 ++- .../selenium/core/driver/IWebFrame.java | 36 +- .../selenium/core/driver/IWebWindow.java | 23 +- .../core/element/IElementActions.java | 73 ++- .../core/element/IFindableAction.java | 78 +-- .../core/element/IKeyboardActions.java | 13 +- .../selenium/core/element/IMouseActions.java | 20 +- .../core/element/ISelectboxActions.java | 124 +++-- .../core/element/ITextboxActions.java | 13 +- .../selenium/core/element/IVerifyElement.java | 63 ++- .../selenium/core/element/IWaitStrategy.java | 46 +- .../selenium/core/enums/AlertDecision.java | 16 +- .../selenium/core/enums/ApplicationType.java | 24 +- .../selenium/core/enums/AvailableBrowser.java | 48 +- .../coteafs/selenium/core/enums/Platform.java | 40 +- .../selenium/core/enums/PlatformOs.java | 48 +- .../coteafs/selenium/core/enums/Protocol.java | 40 +- .../selenium/core/enums/RemoteSource.java | 24 +- .../selenium/core/enums/ScreenState.java | 24 +- .../selenium/core/enums/WaitStrategy.java | 32 +- .../core/page/AbstractPageAction.java | 35 +- .../coteafs/selenium/core/page/IPage.java | 277 +++++------ .../selenium/core/page/IPageAction.java | 49 +- .../selenium/error/DriverNotSetupError.java | 18 +- .../VideoRecordingError.java} | 37 +- .../selenium/listeners/DriverListner.java | 310 ++++++------ .../coteafs/selenium/utils/LogLevel.java | 51 ++ .../selenium/utils/ReportPortalLoggy.java | 42 ++ src/main/resources/coteafs-logger.yaml | 107 ----- .../wasiqb/coteafs/selenium/SeleniumTest.java | 160 ++++--- .../selenium/pages/EditAccountPage.java | 36 +- .../selenium/pages/EditCustomerPage.java | 36 +- .../coteafs/selenium/pages/LoginPage.java | 58 +-- .../coteafs/selenium/pages/MainPage.java | 53 +-- .../selenium/pages/NewAccountPage.java | 44 +- .../selenium/pages/NewCustomerPage.java | 203 ++++---- .../selenium/pages/SuccessAccountPage.java | 44 +- .../selenium/pages/SuccessCustomerPage.java | 44 +- .../coteafs/selenium/pages/SuccessPage.java | 40 +- .../pages/action/DeleteAccountPageAction.java | 34 +- .../action/DeleteCustomerPageAction.java | 34 +- .../pages/action/EditCustomerPageAction.java | 104 ++-- .../pages/action/LoginPageAction.java | 46 +- .../pages/action/NewAccountPageAction.java | 73 +-- .../pages/action/NewCustomerPageAction.java | 127 +++-- src/test/resources/listener-config.yml | 12 + src/test/resources/logger-config.yml | 17 + src/test/resources/selenium-bs-config.yaml | 7 +- src/test/resources/selenium-config.yaml | 11 +- src/test/resources/selenium-grid-config.yaml | 17 +- src/test/resources/selenium-sauce-config.yaml | 15 +- testng-all-browsers.xml | 8 + testng.xml | 85 ++-- 103 files changed, 3810 insertions(+), 3977 deletions(-) create mode 100644 checkstyle-suppressions.xml create mode 100644 checkstyle.xml delete mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/config/DataCategory.java delete mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/config/DataSet.java create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/config/RecorderSetting.java create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/core/BrowserSession.java create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/CustomScreenRecorder.java create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/DriverSession.java create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ParallelSession.java delete mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScriptAction.java rename src/main/java/com/github/wasiqb/coteafs/selenium/{core/base/driver/AbstractDriverAction.java => error/VideoRecordingError.java} (50%) create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/utils/LogLevel.java create mode 100644 src/main/java/com/github/wasiqb/coteafs/selenium/utils/ReportPortalLoggy.java delete mode 100644 src/main/resources/coteafs-logger.yaml create mode 100644 src/test/resources/listener-config.yml create mode 100644 src/test/resources/logger-config.yml 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 driverThread = new ThreadLocal <> (); - private static final Logger LOG = LogManager - .getLogger (AbstractDriver.class); - - /** - * @param platform - * target platform - * @author Wasiq Bhamla - * @since 26-Jul-2019 - */ - protected AbstractDriver (final Platform platform) { - super (platform, OS.platform ()); - } - - @Override - public D getDriver () { - return (D) driverThread.get (); - } +public abstract class AbstractDriver extends PlatformAction implements IDriver { + private static final Loggy LOG = Loggy.init (); - @Override - public boolean isRunning () { - return ((RemoteWebDriver) getDriver ()).getSessionId () != null; - } + /** + * @param platform target platform + * @author Wasiq Bhamla + * @since 26-Jul-2019 + */ + protected AbstractDriver (final Platform platform) { + super (platform, OS.platform ()); + } - protected void driver (final D driver) { - driverThread.set (driver); - } + @Override + public boolean isRunning () { + return ((RemoteWebDriver) getDriver ()).getSessionId () != null; + } - protected void setupDriverOptions () { - final PlaybackSetting playback = appSetting ().getPlayback (); - final DelaySetting delays = playback.getDelays (); - manageTimeouts (t -> t.pageLoadTimeout (delays.getPageLoad (), SECONDS)); - manageTimeouts (t -> t.setScriptTimeout (delays.getScriptLoad (), SECONDS)); - manageTimeouts (t -> t.implicitlyWait (delays.getImplicit (), SECONDS)); - manageOptions (Options::deleteAllCookies); - setScreenSize (playback); - } + protected void setupDriverOptions () { + final PlaybackSetting playback = appSetting ().getPlayback (); + final DelaySetting delays = playback.getDelays (); + manageTimeouts (t -> t.pageLoadTimeout (delays.getPageLoad (), SECONDS)); + manageTimeouts (t -> t.setScriptTimeout (delays.getScriptLoad (), SECONDS)); + manageTimeouts (t -> t.implicitlyWait (delays.getImplicit (), SECONDS)); + manageOptions (Options::deleteAllCookies); + setScreen (playback); + } - private void manageOptions (final Consumer options) { - options.accept (getDriver ().manage ()); - } + private void manageOptions (final Consumer options) { + options.accept (getDriver ().manage ()); + } - private void manageTimeouts (final Consumer timeouts) { - timeouts.accept (getDriver ().manage () - .timeouts ()); - } + private void manageTimeouts (final Consumer timeouts) { + timeouts.accept (getDriver ().manage () + .timeouts ()); + } - private void manageWindow (final Consumer window) { - window.accept (getDriver ().manage () - .window ()); - } + private void manageWindow (final Consumer window) { + window.accept (getDriver ().manage () + .window ()); + } - private void setScreenSize (final PlaybackSetting playback) { - final ScreenState state = playback.getScreenState (); - if (getPlatform () == DESKTOP) { - LOG.info ("Setting screen size of Browser to {}...", state); - switch (state) { - case FULL_SCREEN: - manageWindow (Window::fullscreen); - break; - case MAXIMIZED: - manageWindow (Window::maximize); - break; - case NORMAL: - default: - final ScreenResolution resolution = playback.getScreenResolution (); - LOG.info ("Setting screen resolution to [{}]...", resolution); - manageWindow (w -> w - .setSize (new Dimension (resolution.getWidth (), resolution.getHeight ()))); - break; - } - } - } + private void setScreen (final PlaybackSetting playback) { + final ScreenState state = playback.getScreenState (); + if (getPlatform () == DESKTOP) { + LOG.i ("Setting screen size of Browser to {}...", state); + switch (state) { + case FULL_SCREEN: + manageWindow (Window::fullscreen); + break; + case MAXIMIZED: + manageWindow (Window::maximize); + break; + case NORMAL: + default: + final ScreenResolution resolution = playback.getScreenResolution (); + LOG.i ("Setting screen resolution to [{}]...", resolution); + manageWindow (w -> w.setSize (new Dimension (resolution.getWidth (), resolution.getHeight ()))); + manageWindow (w -> w.setPosition (new Point (0, 0))); + break; + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AlertAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AlertAction.java index c189ef1..fd54c26 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AlertAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AlertAction.java @@ -15,45 +15,46 @@ */ package com.github.wasiqb.coteafs.selenium.core.base.driver; +import static com.github.wasiqb.coteafs.selenium.listeners.DriverListner.setAlias; import static com.google.common.truth.Truth.assertThat; -import org.openqa.selenium.Alert; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; - import com.github.wasiqb.coteafs.selenium.core.driver.IAlertAction; import com.github.wasiqb.coteafs.selenium.core.enums.AlertDecision; import com.google.common.truth.StringSubject; +import org.openqa.selenium.Alert; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 * @param */ -public class AlertAction extends ScreenAction implements IAlertAction { - AlertAction (final D driver) { - super (driver); - } +public class AlertAction extends ScreenAction implements IAlertAction { + AlertAction (final D driver) { + super (driver); + } - @Override - public String alert (final AlertDecision decision) { - final Alert alert = driverWait ().until (ExpectedConditions.alertIsPresent ()); - String message = null; - if (alert != null) { - message = alert.getText (); - if (decision == AlertDecision.ACCEPT) { - alert.accept (); - } - else { - alert.dismiss (); - } - } - return message; - } + @Override + public String alert (final AlertDecision decision) { + final Alert alert = driverWait ().until (ExpectedConditions.alertIsPresent ()); + String message = null; + if (alert != null) { + message = alert.getText (); + setAlias (message); + if (decision == AlertDecision.ACCEPT) { + alert.accept (); + } else { + alert.dismiss (); + } + } + return message; + } - @Override - public StringSubject verifyAlertMessage (final AlertDecision decision) { - final String actual = alert (decision); - return assertThat (actual); - } + @Override + public StringSubject verifyAlertMessage (final AlertDecision decision) { + final String actual = alert (decision); + return assertThat (actual); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/BaseDriverAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/BaseDriverAction.java index 6aa872a..410b62e 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/BaseDriverAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/BaseDriverAction.java @@ -21,42 +21,55 @@ import java.util.function.Consumer; import java.util.function.Function; +import com.github.wasiqb.coteafs.selenium.core.driver.IScriptAction; +import com.github.wasiqb.coteafs.selenium.core.driver.IWaitAction; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.events.EventFiringWebDriver; import org.openqa.selenium.support.ui.WebDriverWait; -import com.github.wasiqb.coteafs.selenium.core.driver.IWaitAction; - /** + * @param * @author Wasiq Bhamla * @since 27-Jul-2019 - * @param */ -public class BaseDriverAction implements IWaitAction { - protected D driver; - private final WebDriverWait wait; - - BaseDriverAction (final D driver) { - this.driver = driver; - this.wait = new WebDriverWait (driver, ofSeconds (appSetting ().getPlayback () - .getDelays () - .getExplicit ())); - } - - @Override - public D driver () { - return this.driver; - } - - @Override - public WebDriverWait driverWait () { - return this.wait; - } - - protected E get (final Function func) { - return func.apply (this.driver); - } - - protected void perform (final Consumer action) { - action.accept (this.driver); - } +public class BaseDriverAction implements IWaitAction, IScriptAction { + protected D driver; + private final WebDriverWait wait; + + BaseDriverAction (final D driver) { + this.driver = driver; + this.wait = new WebDriverWait (driver, ofSeconds (appSetting ().getPlayback () + .getDelays () + .getExplicit ()).getSeconds ()); + } + + @Override + public D driver () { + return this.driver; + } + + @Override + public WebDriverWait driverWait () { + return this.wait; + } + + @SuppressWarnings ("unchecked") + @Override + public T execute (final String script, final Object... args) { + return (T) get (d -> { + if (d instanceof EventFiringWebDriver) { + return ((EventFiringWebDriver) d).executeScript (script, args); + } + return ((RemoteWebDriver) d).executeScript (script, args); + }); + } + + protected E get (final Function func) { + return func.apply (this.driver); + } + + protected void perform (final Consumer action) { + action.accept (this.driver); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/CustomScreenRecorder.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/CustomScreenRecorder.java new file mode 100644 index 0000000..e9e178a --- /dev/null +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/CustomScreenRecorder.java @@ -0,0 +1,135 @@ +/* + * 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.base.driver; + +import static com.github.wasiqb.coteafs.error.util.ErrorUtil.handleError; +import static com.github.wasiqb.coteafs.selenium.config.ConfigUtil.appSetting; +import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.FILTER_PKG; +import static java.text.MessageFormat.format; +import static org.monte.media.FormatKeys.EncodingKey; +import static org.monte.media.FormatKeys.FrameRateKey; +import static org.monte.media.FormatKeys.KeyFrameIntervalKey; +import static org.monte.media.FormatKeys.MIME_AVI; +import static org.monte.media.FormatKeys.MediaTypeKey; +import static org.monte.media.FormatKeys.MimeTypeKey; +import static org.monte.media.Registry.getInstance; +import static org.monte.media.VideoFormatKeys.CompressorNameKey; +import static org.monte.media.VideoFormatKeys.DepthKey; +import static org.monte.media.VideoFormatKeys.ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE; +import static org.monte.media.VideoFormatKeys.QualityKey; + +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.github.wasiqb.coteafs.logger.Loggy; +import com.github.wasiqb.coteafs.selenium.config.RecorderSetting; +import com.github.wasiqb.coteafs.selenium.error.VideoRecordingError; +import org.monte.media.Format; +import org.monte.media.FormatKeys.MediaType; +import org.monte.media.math.Rational; +import org.monte.screenrecorder.ScreenRecorder; + +/** + * @author Wasiq Bhamla + * @since 27-Oct-2019 + */ +class CustomScreenRecorder extends ScreenRecorder { + private static final Loggy LOG = Loggy.init (); + private static final RecorderSetting RECORDER_SETTING = appSetting ().getPlayback () + .getRecording (); + private static ScreenRecorder screenRecorder; + + static void startRecording () { + if (checkIfEnabled ()) { + LOG.i ("Started Video screen recording..."); + final File file = new File (RECORDER_SETTING.getPath ()); + + final Dimension screenSize = Toolkit.getDefaultToolkit () + .getScreenSize (); + final int width = screenSize.width; + final int height = screenSize.height; + + final Rectangle captureSize = new Rectangle (0, 0, width, height); + + final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment () + .getDefaultScreenDevice () + .getDefaultConfiguration (); + + try { + screenRecorder = new CustomScreenRecorder (gc, captureSize, + new Format (MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI), + new Format (MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, + CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey, + Rational.valueOf (15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60), + new Format (MediaTypeKey, MediaType.VIDEO, EncodingKey, "black", FrameRateKey, + Rational.valueOf (30)), null, file); + screenRecorder.start (); + } catch (final IOException | AWTException e) { + handleError (FILTER_PKG, e).forEach (LOG::e); + throw new VideoRecordingError ("Error while starting video recording.", e); + } + } else { + LOG.w ("Video screen recording is Disabled, cannot start..."); + } + } + + static void stopRecording () { + if (checkIfEnabled ()) { + LOG.i ("Stopping Video screen recording..."); + try { + screenRecorder.stop (); + } catch (final IOException e) { + handleError (FILTER_PKG, e).forEach (LOG::e); + throw new VideoRecordingError ("Error while stopping video recording.", e); + } + } else { + LOG.w ("Video screen recording is Disabled, cannot stop..."); + } + } + + private static boolean checkIfEnabled () { + return RECORDER_SETTING != null && RECORDER_SETTING.isEnable (); + } + + private final String prefix; + + private CustomScreenRecorder (final GraphicsConfiguration cfg, final Rectangle captureArea, final Format fileFormat, + final Format screenFormat, final Format mouseFormat, final Format audioFormat, final File movieFolder) + throws IOException, AWTException { + super (cfg, captureArea, fileFormat, screenFormat, mouseFormat, audioFormat, movieFolder); + this.prefix = RECORDER_SETTING.getPrefix (); + } + + @Override + protected File createMovieFile (final Format fileFormat) throws IOException { + if (!this.movieFolder.exists ()) { + this.movieFolder.mkdirs (); + } else if (!this.movieFolder.isDirectory ()) { + throw new IOException (format ("\"{0}\" is not a directory.", this.movieFolder)); + } + final SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyyMMdd-HHmmss"); + return new File (this.movieFolder, format ("{0}-{1}.{2}", this.prefix, dateFormat.format (new Date ()), + getInstance ().getExtension (fileFormat))); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/DriverSession.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/DriverSession.java new file mode 100644 index 0000000..ea0a747 --- /dev/null +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/DriverSession.java @@ -0,0 +1,100 @@ +/* + * 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.base.driver; + +import java.util.HashMap; +import java.util.Map; + +import org.openqa.selenium.WebDriver; + +/** + * @author Wasiq Bhamla + * @param + * @since 27-Sep-2019 + */ +public class DriverSession { + private final Map context; + private D driver; + + /** + * @author Wasiq Bhamla + * @param driver + * @since 28-Sep-2019 + */ + public DriverSession (final D driver) { + this.driver = driver; + this.context = new HashMap<> (); + } + + /** + * @author Wasiq Bhamla + * @since 28-Sep-2019 + */ + public void clearContext () { + this.context.clear (); + } + + /** + * @author Wasiq Bhamla + * @since 28-Sep-2019 + */ + public void close () { + clearContext (); + this.driver.quit (); + this.driver = null; + } + + /** + * @author Wasiq Bhamla + * @since 28-Sep-2019 + * @param + * @param key + * @return context + */ + @SuppressWarnings ("unchecked") + public T getContext (final String key) { + return (T) this.context.get (key); + } + + /** + * @author Wasiq Bhamla + * @since 27-Sep-2019 + * @return the driver + */ + public D getDriver () { + return this.driver; + } + + /** + * @author Wasiq Bhamla + * @since 28-Sep-2019 + * @param + * @param key + * @param value + */ + public void setContext (final String key, final T value) { + this.context.put (key, value); + } + + /** + * @author Wasiq Bhamla + * @since 28-Sep-2019 + * @param driver the driver to set + */ + public void setDriver (final D driver) { + this.driver = driver; + } +} \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ParallelSession.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ParallelSession.java new file mode 100644 index 0000000..c5997ca --- /dev/null +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ParallelSession.java @@ -0,0 +1,56 @@ +/* + * 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.base.driver; + +import com.github.wasiqb.coteafs.selenium.core.BrowserSession; + +/** + * @author Wasiq Bhamla + * @since 27-Sep-2019 + */ +public class ParallelSession { + private static final ThreadLocal SESSION = new ThreadLocal<> (); + + /** + * @author Wasiq Bhamla + * @since 28-Nov-2019 + */ + public static void close () { + SESSION.remove (); + } + + /** + * @return session + * @author Wasiq Bhamla + * @since 28-Sep-2019 + */ + public static BrowserSession getSession () { + return SESSION.get (); + } + + /** + * @param session + * @author Wasiq Bhamla + * @since 28-Sep-2019 + */ + public static void setSession (final BrowserSession session) { + SESSION.set (session); + } + + private ParallelSession () { + // Utility class. + } +} \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/PlatformAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/PlatformAction.java index b8496ff..55cd92b 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/PlatformAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/PlatformAction.java @@ -24,29 +24,27 @@ * @since 26-Jul-2019 */ public class PlatformAction implements IPlatformAction { - private final Platform platform; - private final PlatformOs platformOs; + private final Platform platform; + private final PlatformOs platformOs; - /** - * @author Wasiq Bhamla - * @since 26-Jul-2019 - * @param platform - * platform - * @param platformOs - * platformOs - */ - PlatformAction (final Platform platform, final PlatformOs platformOs) { - this.platform = platform; - this.platformOs = platformOs; - } + /** + * @author Wasiq Bhamla + * @since 26-Jul-2019 + * @param platform platform + * @param platformOs platformOs + */ + PlatformAction (final Platform platform, final PlatformOs platformOs) { + this.platform = platform; + this.platformOs = platformOs; + } - @Override - public Platform getPlatform () { - return this.platform; - } + @Override + public Platform getPlatform () { + return this.platform; + } - @Override - public PlatformOs getPlatformOs () { - return this.platformOs; - } + @Override + public PlatformOs getPlatformOs () { + return this.platformOs; + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScreenAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScreenAction.java index dc43b43..aab4c9a 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScreenAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScreenAction.java @@ -15,8 +15,13 @@ */ package com.github.wasiqb.coteafs.selenium.core.base.driver; +import static com.github.wasiqb.coteafs.error.util.ErrorUtil.handleError; import static com.github.wasiqb.coteafs.selenium.config.ConfigUtil.appSetting; +import static com.github.wasiqb.coteafs.selenium.constants.ConfigKeys.FILTER_PKG; +import static com.google.common.truth.Truth.assertThat; import static java.lang.String.format; +import static java.lang.Thread.currentThread; +import static java.lang.Thread.sleep; import static org.apache.commons.io.FileUtils.copyFile; import java.io.File; @@ -24,57 +29,106 @@ import java.text.SimpleDateFormat; import java.util.Calendar; -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.ScreenshotSetting; +import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; +import com.github.wasiqb.coteafs.selenium.core.driver.IScreenAction; +import com.google.common.truth.StringSubject; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; -import com.github.wasiqb.coteafs.selenium.config.ScreenshotSetting; -import com.github.wasiqb.coteafs.selenium.core.driver.IScreenAction; - /** + * @param * @author Wasiq Bhamla * @since 27-Jul-2019 - * @param */ -public class ScreenAction extends ScriptAction implements IScreenAction { - private static final Logger LOG = LogManager.getLogger (AbstractDriverAction.class); +public class ScreenAction extends BaseDriverAction implements IScreenAction, IDriverActions { + private static final Loggy LOG = Loggy.init (); + + protected static void pause (final long delay) { + try { + sleep (delay); + } catch (final InterruptedException e) { + LOG.e ("Error while pausing: {}", e.getMessage ()); + currentThread ().interrupt (); + } + } + + ScreenAction (final D driver) { + super (driver); + } + + @Override + public byte[] attachScreenshot () { + return get (d -> ((RemoteWebDriver) d).getScreenshotAs (OutputType.BYTES)); + } + + @Override + public File saveScreenshot () { + final ScreenshotSetting setting = appSetting ().getPlayback () + .getScreenshot (); + final String path = setting.getPath (); + final String prefix = setting.getPrefix (); + final SimpleDateFormat date = new SimpleDateFormat ("yyyyMMdd-HHmmss"); + final String timeStamp = date.format (Calendar.getInstance () + .getTime ()); + final String fileName = "%s/%s-%s.%s"; + return saveScreenshot (format (fileName, path, prefix, timeStamp, "jpeg")); + } + + @Override + public File saveScreenshot (final String path) { + final String msg = "Capturing screenshot and saving at [{}]..."; + LOG.i (msg, path); + try { + final File source = ((TakesScreenshot) this.driver).getScreenshotAs (OutputType.FILE); + final File destination = new File (path); + copyFile (source, destination); + return destination; + } catch (final IOException e) { + LOG.e ("Error while saving screenshot.", e); + handleError (FILTER_PKG, e).forEach (LOG::e); + } + return null; + } - ScreenAction (final D driver) { - super (driver); - } + /* + * (non-Javadoc) + * @see @see + * com.github.wasiqb.coteafs.selenium.core.driver.IScreenAction#startRecording() + */ + @Override + public void startRecording () { + try { + CustomScreenRecorder.startRecording (); + } catch (final Exception e) { + handleError (FILTER_PKG, e).forEach (LOG::e); + } + } - @Override - public byte [] attachScreenshot () { - return get (d -> ((RemoteWebDriver) d).getScreenshotAs (OutputType.BYTES)); - } + /* + * (non-Javadoc) + * @see @see + * com.github.wasiqb.coteafs.selenium.core.driver.IScreenAction#stopRecording() + */ + @Override + public void stopRecording () { + try { + CustomScreenRecorder.stopRecording (); + } catch (final Exception e) { + handleError (FILTER_PKG, e).forEach (LOG::e); + } + } - @Override - public void saveScreenshot () { - final ScreenshotSetting setting = appSetting ().getPlayback () - .getScreenshot (); - final String path = setting.getPath (); - final String prefix = setting.getPrefix (); - final SimpleDateFormat date = new SimpleDateFormat ("yyyyMMdd-HHmmss"); - final String timeStamp = date.format (Calendar.getInstance () - .getTime ()); - final String fileName = "%s/%s-%s.%s"; - saveScreenshot (format (fileName, path, prefix, timeStamp, "jpeg")); - } + @Override + public String title () { + return get (WebDriver::getTitle); + } - @Override - public void saveScreenshot (final String path) { - final String msg = "Capturing screenshot and saving at [{}]..."; - LOG.info (msg, path); - try { - final File srcFiler = ((TakesScreenshot) this.driver).getScreenshotAs (OutputType.FILE); - copyFile (srcFiler, new File (path)); - } - catch (final IOException e) { - LOG.error ("Error while saving screenshot.", e); - LOG.catching (e); - } - } + @Override + public StringSubject verifyTitle () { + return assertThat (title ()); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScriptAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScriptAction.java deleted file mode 100644 index c23ee57..0000000 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/ScriptAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.base.driver; - -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.events.EventFiringWebDriver; - -import com.github.wasiqb.coteafs.selenium.core.driver.IScriptAction; - -/** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @param - */ -@SuppressWarnings ("unchecked") -public class ScriptAction extends BaseDriverAction - implements IScriptAction { - ScriptAction (final D driver) { - super (driver); - } - - @Override - public T execute (final String script, final Object... args) { - return (T) get (d -> { - if (d instanceof EventFiringWebDriver) - return ((EventFiringWebDriver) d).executeScript (script, args); - return ((RemoteWebDriver) d).executeScript (script, args); - }); - } -} \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/WebDriverAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/WebDriverAction.java index e87c882..dc326c7 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/WebDriverAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/WebDriverAction.java @@ -15,48 +15,46 @@ */ package com.github.wasiqb.coteafs.selenium.core.base.driver; -import org.openqa.selenium.WebDriver; - import com.github.wasiqb.coteafs.selenium.core.driver.IWebDriverActions; +import org.openqa.selenium.WebDriver; /** - * @author Wasiq Bhamla * @param + * @author Wasiq Bhamla * @since 27-Jul-2019 */ -public class WebDriverAction extends AbstractDriverAction - implements IWebDriverActions { - protected WebDriverAction (final D driver) { - super (driver); - } - - @Override - public void back () { - perform (d -> d.navigate () - .back ()); - } - - @Override - public void deleteCookies () { - perform (d -> d.manage () - .deleteAllCookies ()); - } - - @Override - public void forward () { - perform (d -> d.navigate () - .forward ()); - } - - @Override - public void navigateTo (final String url) { - perform (d -> d.navigate () - .to (url)); - } - - @Override - public void refresh () { - perform (d -> d.navigate () - .refresh ()); - } +public class WebDriverAction extends AlertAction implements IWebDriverActions { + protected WebDriverAction (final D driver) { + super (driver); + } + + @Override + public void back () { + perform (d -> d.navigate () + .back ()); + } + + @Override + public void deleteCookies () { + perform (d -> d.manage () + .deleteAllCookies ()); + } + + @Override + public void forward () { + perform (d -> d.navigate () + .forward ()); + } + + @Override + public void navigateTo (final String url) { + perform (d -> d.navigate () + .to (url)); + } + + @Override + public void refresh () { + perform (d -> d.navigate () + .refresh ()); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/AbstractElementAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/AbstractElementAction.java index 2f8924e..50fc15f 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/AbstractElementAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/AbstractElementAction.java @@ -21,17 +21,17 @@ import java.util.List; import java.util.stream.Collectors; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.Select; - import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; 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 org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 @@ -40,154 +40,152 @@ * @param */ @SuppressWarnings ("unchecked") -public class AbstractElementAction > extends FindableAction - implements ITextboxActions, ISelectboxActions { - protected AbstractElementAction (final B browserAction, final By by) { - super (browserAction, by); - } - - protected AbstractElementAction (final B browserAction, final By by, - final WaitStrategy strategy) { - super (browserAction, by, strategy); - } - - protected AbstractElementAction (final B browserAction, final E element) { - super (browserAction, element); - } - - protected AbstractElementAction (final B browserAction, final E element, - final WaitStrategy strategy) { - super (browserAction, element, strategy); - } - - @Override - public void click () { - perform (e -> { - pause (this.delays.getBeforeClick ()); - e.click (); - pause (this.delays.getAfterClick ()); - }); - } - - @Override - public void deselectAll () { - perform (e -> { - final Select select = new Select (e); - select.deselectAll (); - }); - } - - @Override - public void deselectByIndex (final int index) { - perform (e -> { - final Select select = new Select (e); - select.deselectByIndex (index); - }); - } - - @Override - public void deselectByText (final String value) { - perform (e -> { - final Select select = new Select (e); - select.deselectByVisibleText (value); - }); - } - - @Override - public void deselectByValue (final String value) { - perform (e -> { - final Select select = new Select (e); - select.deselectByValue (value); - }); - } - - @Override - public void enterText (final String text) { - perform (e -> { - if (isNoneEmpty (text)) { - pause (this.delays.getBeforeTyping ()); - e.sendKeys (text); - pause (this.delays.getAfterTyping ()); - } - }); - } - - @Override - public T find (final By byLocator, final WaitStrategy strategy) { - waitForStrategy (byLocator, strategy); - return get ( - e -> (T) new AbstractElementAction <> (this.browserAction, e.findElement (byLocator))); - } - - @Override - public List finds (final By byLocator, - final WaitStrategy strategy) { - waitForStrategy (byLocator, strategy); - return get (e -> e.findElements (byLocator)).stream () - .map (e -> (T) new AbstractElementAction <> (this.browserAction, e)) - .collect (Collectors.toList ()); - } - - @Override - public void hover () { - perform (e -> this.actions.pause (ofMillis (this.delays.getBeforeMouseMove ())) - .moveToElement (e) - .pause (ofMillis (this.delays.getAfterMouseMove ())) - .perform ()); - } - - @Override - public boolean isMultiSelect () { - return get (e -> { - final Select select = new Select (e); - return select.isMultiple (); - }); - } - - @Override - public List options () { - return get (e -> { - final Select select = new Select (e); - return select.getOptions () - .stream () - .map (o -> (T) new AbstractElementAction <> (this.browserAction, o)) - .collect (Collectors.toList ()); - }); - } - - @Override - public void selectByIndex (final int index) { - perform (e -> { - final Select select = new Select (e); - select.selectByIndex (index); - }); - } - - @Override - public void selectByText (final String value) { - perform (e -> { - final Select select = new Select (e); - select.selectByVisibleText (value); - }); - } - - @Override - public void selectByValue (final String value) { - perform (e -> { - final Select select = new Select (e); - select.selectByValue (value); - }); - } - - @Override - public List selectedOptions () { - return get (e -> { - final Select select = new Select (e); - return select.getAllSelectedOptions () - .stream () - .map (o -> (T) new AbstractElementAction <> (this.browserAction, o)) - .collect (Collectors.toList ()); - }); - } +public class AbstractElementAction> + extends FindableAction implements ITextboxActions, ISelectboxActions { + protected AbstractElementAction (final B browserAction, final By by, final String name) { + super (browserAction, by, name); + } + + protected AbstractElementAction (final B browserAction, final By by, final String name, + final WaitStrategy strategy) { + super (browserAction, by, name, strategy); + } + + protected AbstractElementAction (final B browserAction, final E element, final String name) { + super (browserAction, element, name); + } + + protected AbstractElementAction (final B browserAction, final E element, final String name, + final WaitStrategy strategy) { + super (browserAction, element, name, strategy); + } + + @Override + public void click () { + perform (e -> { + pause (this.delays.getBeforeClick ()); + e.click (); + pause (this.delays.getAfterClick ()); + }); + } + + @Override + public void deselectAll () { + perform (e -> { + final Select select = new Select (e); + select.deselectAll (); + }); + } + + @Override + public void deselectByIndex (final int index) { + perform (e -> { + final Select select = new Select (e); + select.deselectByIndex (index); + }); + } + + @Override + public void deselectByText (final String value) { + perform (e -> { + final Select select = new Select (e); + select.deselectByVisibleText (value); + }); + } + + @Override + public void deselectByValue (final String value) { + perform (e -> { + final Select select = new Select (e); + select.deselectByValue (value); + }); + } + + @Override + public void enterText (final String text) { + perform (e -> { + if (isNoneEmpty (text)) { + pause (this.delays.getBeforeKeyPress ()); + e.sendKeys (text); + pause (this.delays.getAfterKeyPress ()); + } + }); + } + + @Override + public T find (final By byLocator, final String name, final WaitStrategy strategy) { + waitForStrategy (byLocator, strategy); + return get (e -> (T) new AbstractElementAction<> (this.browserAction, e.findElement (byLocator), name)); + } + + @Override + public List finds (final By byLocator, final String name, + final WaitStrategy strategy) { + waitForStrategy (byLocator, strategy); + return get (e -> e.findElements (byLocator)).stream () + .map (e -> (T) new AbstractElementAction<> (this.browserAction, e, name)) + .collect (Collectors.toList ()); + } + + @Override + public void hover () { + perform (e -> this.actions.pause (ofMillis (this.delays.getBeforeMouseMove ())) + .moveToElement (e) + .pause (ofMillis (this.delays.getAfterMouseMove ())) + .perform ()); + } + + @Override + public boolean isMultiSelect () { + return get (e -> { + final Select select = new Select (e); + return select.isMultiple (); + }); + } + + @Override + public List options () { + return get (e -> { + final Select select = new Select (e); + return select.getOptions () + .stream () + .map (o -> (T) new AbstractElementAction<> (this.browserAction, o, o.getText ())) + .collect (Collectors.toList ()); + }); + } + + @Override + public void selectByIndex (final int index) { + perform (e -> { + final Select select = new Select (e); + select.selectByIndex (index); + }); + } + + @Override + public void selectByText (final String value) { + perform (e -> { + final Select select = new Select (e); + select.selectByVisibleText (value); + }); + } + + @Override + public void selectByValue (final String value) { + perform (e -> { + final Select select = new Select (e); + select.selectByValue (value); + }); + } + + @Override + public List selectedOptions () { + return get (e -> { + final Select select = new Select (e); + return select.getAllSelectedOptions () + .stream () + .map (o -> (T) new AbstractElementAction<> (this.browserAction, o, o.getText ())) + .collect (Collectors.toList ()); + }); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/BaseElementAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/BaseElementAction.java index ca37e88..856c6d8 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/BaseElementAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/BaseElementAction.java @@ -15,6 +15,7 @@ */ package com.github.wasiqb.coteafs.selenium.core.base.element; +import static com.github.wasiqb.coteafs.selenium.listeners.DriverListner.setAlias; import static java.lang.Thread.currentThread; import static java.lang.Thread.sleep; import static java.text.MessageFormat.format; @@ -28,20 +29,19 @@ import java.util.function.Consumer; import java.util.function.Function; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.WebDriverWait; - +import com.github.wasiqb.coteafs.logger.Loggy; import com.github.wasiqb.coteafs.selenium.config.ConfigUtil; import com.github.wasiqb.coteafs.selenium.config.DelaySetting; import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; import com.github.wasiqb.coteafs.selenium.core.element.IWaitStrategy; import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.WebDriverWait; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 @@ -50,183 +50,179 @@ * @param */ @SuppressWarnings ("unchecked") -public class BaseElementAction > implements IWaitStrategy { - private static final Logger LOG = LogManager.getLogger (BaseElementAction.class); - - static void pause (final long delay) { - try { - sleep (delay); - } - catch (final InterruptedException e) { - LOG.error ("Error while pausing: {}", e.getMessage ()); - currentThread ().interrupt (); - } - } - - final Actions actions; - final B browserAction; - final DelaySetting delays; - private boolean alreadyHighlighted; - private By by; - private final D driver; - private E element; - private WaitStrategy strategy; - private String style; - private boolean useBy; - private final WebDriverWait wait; - - BaseElementAction (final B browserAction, final By by) { - this (browserAction); - this.by = by; - this.useBy = true; - } - - BaseElementAction (final B browserAction, final By by, final WaitStrategy strategy) { - this (browserAction, by); - if (strategy != null) { - this.strategy = strategy; - } - } - - BaseElementAction (final B browserAction, final E element) { - this (browserAction); - this.element = element; - this.useBy = false; - } - - BaseElementAction (final B browserAction, final E element, final WaitStrategy strategy) { - this (browserAction, element); - if (strategy != null) { - this.strategy = strategy; - } - } - - private BaseElementAction (final B browserAction) { - this.browserAction = browserAction; - this.driver = browserAction.driver (); - this.actions = new Actions (this.driver); - this.wait = browserAction.driverWait (); - this.alreadyHighlighted = false; - this.delays = ConfigUtil.appSetting () - .getPlayback () - .getDelays (); - this.strategy = WaitStrategy.NONE; - } - - @Override - public void waitUntilAttributeIs (final String attribute, final String value) { - if (this.useBy) { - waitUntilLocatorAttributeIs (attribute, value); - } - else { - this.wait.until (attributeToBe (this.element, attribute, value)); - } - } - - @Override - public void waitUntilClickable () { - if (this.useBy) { - waitUntilLocatorClickable (); - } - else { - this.wait.until (elementToBeClickable (this.element)); - } - } - - @Override - public void waitUntilInvisible () { - if (this.useBy) { - waitUntilLocatorInvisible (); - } - else { - this.wait.until (invisibilityOf (this.element)); - } - } - - @Override - public void waitUntilVisible () { - if (this.useBy) { - waitUntilLocatorVisible (); - } - else { - this.wait.until (visibilityOf (this.element)); - } - } - - protected T get (final Function func) { - prepareForAction ("green"); - return func.apply (this.element); - } - - protected void perform (final Consumer action) { - prepareForAction ("red"); - action.accept (this.element); - } - - protected void waitForStrategy (final By locator, final WaitStrategy newStrategy) { - final BaseElementAction elementAction = new BaseElementAction <> (this.browserAction, locator, newStrategy); - elementAction.waitForStrategy (); - } - - private void highlight (final String color) { - if (!this.alreadyHighlighted) { - this.style = this.element.getAttribute ("style"); - this.browserAction.execute ( - "arguments[0].setAttribute('style', arguments[1] + arguments[2]);", this.element, - this.style, format ("color: {0}; border: 3px solid {0};", color)); - } - } - - private void prepareForAction (final String color) { - waitForStrategy (); - highlight (color); - pause (this.delays.getHighlight ()); - unhighlight (); - } - - private void unhighlight () { - if (!this.alreadyHighlighted) { - this.browserAction.execute ("arguments[0].setAttribute('style', arguments[1]);", - this.element, this.style); - this.alreadyHighlighted = true; - } - } - - private void waitForStrategy () { - switch (this.strategy) { - case CLICKABLE: - waitUntilClickable (); - break; - case VISIBLE: - waitUntilVisible (); - break; - case INVISIBLE: - waitUntilInvisible (); - break; - case NONE: - default: - if (this.useBy) { - this.element = (E) this.driver.findElement (this.by); - } - break; - } - } - - private void waitUntilLocatorAttributeIs (final String attribute, final String value) { - this.wait.until (attributeToBe (this.by, attribute, value)); - } - - private void waitUntilLocatorClickable () { - this.element = (E) this.wait.until (elementToBeClickable (this.by)); - } - - private void waitUntilLocatorInvisible () { - this.wait.until (invisibilityOfElementLocated (this.by)); - } - - private void waitUntilLocatorVisible () { - this.element = (E) this.wait.until (visibilityOfElementLocated (this.by)); - } +public class BaseElementAction> + implements IWaitStrategy { + private static final Loggy LOG = Loggy.init (); + + static void pause (final long delay) { + try { + sleep (delay); + } catch (final InterruptedException e) { + LOG.e ("Error while pausing: {}", e.getMessage ()); + currentThread ().interrupt (); + } + } + + final Actions actions; + final B browserAction; + final DelaySetting delays; + private boolean alreadyHighlighted; + private By by; + private final D driver; + private E element; + private final String name; + private WaitStrategy strategy; + private String style; + private boolean useBy; + private final WebDriverWait wait; + + BaseElementAction (final B browserAction, final By by, final String name) { + this (browserAction, name); + this.by = by; + this.useBy = true; + } + + BaseElementAction (final B browserAction, final By by, final String name, final WaitStrategy strategy) { + this (browserAction, by, name); + if (strategy != null) { + this.strategy = strategy; + } + } + + BaseElementAction (final B browserAction, final E element, final String name) { + this (browserAction, name); + this.element = element; + this.useBy = false; + } + + BaseElementAction (final B browserAction, final E element, final String name, final WaitStrategy strategy) { + this (browserAction, element, name); + if (strategy != null) { + this.strategy = strategy; + } + } + + private BaseElementAction (final B browserAction, final String name) { + this.browserAction = browserAction; + this.name = name; + this.driver = browserAction.driver (); + this.actions = new Actions (this.driver); + this.wait = browserAction.driverWait (); + this.alreadyHighlighted = false; + this.delays = ConfigUtil.appSetting () + .getPlayback () + .getDelays (); + this.strategy = WaitStrategy.NONE; + } + + @Override + public void waitUntilAttributeIs (final String attribute, final String value) { + if (this.useBy) { + waitUntilLocatorAttributeIs (attribute, value); + } else { + this.wait.until (attributeToBe (this.element, attribute, value)); + } + } + + @Override + public void waitUntilClickable () { + if (this.useBy) { + waitUntilLocatorClickable (); + } else { + this.wait.until (elementToBeClickable (this.element)); + } + } + + @Override + public void waitUntilInvisible () { + if (this.useBy) { + waitUntilLocatorInvisible (); + } else { + this.wait.until (invisibilityOf (this.element)); + } + } + + @Override + public void waitUntilVisible () { + if (this.useBy) { + waitUntilLocatorVisible (); + } else { + this.wait.until (visibilityOf (this.element)); + } + } + + protected T get (final Function func) { + prepareForAction ("green"); + return func.apply (this.element); + } + + protected void perform (final Consumer action) { + prepareForAction ("red"); + action.accept (this.element); + } + + protected void waitForStrategy (final By locator, final WaitStrategy newStrategy) { + final BaseElementAction elementAction = new BaseElementAction<> (this.browserAction, locator, this.name, newStrategy); + elementAction.waitForStrategy (); + } + + private void highlight (final String color) { + if (!this.alreadyHighlighted) { + this.style = this.element.getAttribute ("style"); + this.browserAction.execute ("arguments[0].setAttribute('style', arguments[1] + arguments[2]);", + this.element, this.style, format ("color: {0}; border: 3px solid {0};", color)); + } + } + + private void prepareForAction (final String color) { + waitForStrategy (); + highlight (color); + pause (this.delays.getHighlight ()); + unhighlight (); + setAlias (this.name); + } + + private void unhighlight () { + if (!this.alreadyHighlighted) { + this.browserAction.execute ("arguments[0].setAttribute('style', arguments[1]);", this.element, this.style); + this.alreadyHighlighted = true; + } + } + + private void waitForStrategy () { + switch (this.strategy) { + case CLICKABLE: + waitUntilClickable (); + break; + case VISIBLE: + waitUntilVisible (); + break; + case INVISIBLE: + waitUntilInvisible (); + break; + case NONE: + default: + if (this.useBy) { + this.element = (E) this.driver.findElement (this.by); + } + break; + } + } + + private void waitUntilLocatorAttributeIs (final String attribute, final String value) { + this.wait.until (attributeToBe (this.by, attribute, value)); + } + + private void waitUntilLocatorClickable () { + this.element = (E) this.wait.until (elementToBeClickable (this.by)); + } + + private void waitUntilLocatorInvisible () { + this.wait.until (invisibilityOfElementLocated (this.by)); + } + + private void waitUntilLocatorVisible () { + this.element = (E) this.wait.until (visibilityOfElementLocated (this.by)); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/ElementAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/ElementAction.java index 146add3..00aa4d9 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/ElementAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/ElementAction.java @@ -15,14 +15,14 @@ */ package com.github.wasiqb.coteafs.selenium.core.base.element; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; import com.github.wasiqb.coteafs.selenium.core.element.IElementActions; import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 @@ -30,51 +30,51 @@ * @param * @param */ -public class ElementAction > - extends BaseElementAction implements IElementActions { - protected ElementAction (final B browserAction, final By by) { - super (browserAction, by); - } +public class ElementAction> + extends BaseElementAction implements IElementActions { + protected ElementAction (final B browserAction, final By by, final String name) { + super (browserAction, by, name); + } - protected ElementAction (final B browserAction, final By by, final WaitStrategy strategy) { - super (browserAction, by, strategy); - } + protected ElementAction (final B browserAction, final By by, final String name, final WaitStrategy strategy) { + super (browserAction, by, name, strategy); + } - protected ElementAction (final B browserAction, final E element) { - super (browserAction, element); - } + protected ElementAction (final B browserAction, final E element, final String name) { + super (browserAction, element, name); + } - protected ElementAction (final B browserAction, final E element, final WaitStrategy strategy) { - super (browserAction, element, strategy); - } + protected ElementAction (final B browserAction, final E element, final String name, final WaitStrategy strategy) { + super (browserAction, element, name, strategy); + } - @Override - public String attribute (final String name) { - return get (e -> e.getAttribute (name)); - } + @Override + public String attribute (final String name) { + return get (e -> e.getAttribute (name)); + } - @Override - public void clear () { - perform (WebElement::clear); - } + @Override + public void clear () { + perform (WebElement::clear); + } - @Override - public boolean isDisplayed () { - return get (WebElement::isDisplayed); - } + @Override + public boolean isDisplayed () { + return get (WebElement::isDisplayed); + } - @Override - public boolean isEnabled () { - return get (WebElement::isEnabled); - } + @Override + public boolean isEnabled () { + return get (WebElement::isEnabled); + } - @Override - public boolean isSelected () { - return get (WebElement::isSelected); - } + @Override + public boolean isSelected () { + return get (WebElement::isSelected); + } - @Override - public String text () { - return get (WebElement::getText); - } + @Override + public String text () { + return get (WebElement::getText); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/FindableAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/FindableAction.java index 297ad4d..eeb327e 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/FindableAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/FindableAction.java @@ -17,15 +17,15 @@ import java.util.List; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; import com.github.wasiqb.coteafs.selenium.core.element.IFindableAction; import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 @@ -33,31 +33,31 @@ * @param * @param */ -public abstract class FindableAction > extends KeyboardAction implements IFindableAction { - protected FindableAction (final B browserAction, final By by) { - super (browserAction, by); - } - - protected FindableAction (final B browserAction, final By by, final WaitStrategy strategy) { - super (browserAction, by, strategy); - } - - protected FindableAction (final B browserAction, final E element) { - super (browserAction, element); - } - - protected FindableAction (final B browserAction, final E element, final WaitStrategy strategy) { - super (browserAction, element, strategy); - } - - @Override - public T find (final By byLocator) { - return find (byLocator, WaitStrategy.NONE); - } - - @Override - public List finds (final By byLocator) { - return finds (byLocator, WaitStrategy.NONE); - } +public abstract class FindableAction> + extends KeyboardAction implements IFindableAction { + protected FindableAction (final B browserAction, final By by, final String name) { + super (browserAction, by, name); + } + + protected FindableAction (final B browserAction, final By by, final String name, final WaitStrategy strategy) { + super (browserAction, by, name, strategy); + } + + protected FindableAction (final B browserAction, final E element, final String name) { + super (browserAction, element, name); + } + + protected FindableAction (final B browserAction, final E element, final String name, final WaitStrategy strategy) { + super (browserAction, element, name, strategy); + } + + @Override + public T find (final By byLocator, final String name) { + return find (byLocator, name, WaitStrategy.NONE); + } + + @Override + public List finds (final By byLocator, final String name) { + return finds (byLocator, name, WaitStrategy.NONE); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/KeyboardAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/KeyboardAction.java index 099e895..ac1fd8a 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/KeyboardAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/KeyboardAction.java @@ -15,15 +15,15 @@ */ package com.github.wasiqb.coteafs.selenium.core.base.element; +import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; +import com.github.wasiqb.coteafs.selenium.core.element.IKeyboardActions; +import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; + import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; -import com.github.wasiqb.coteafs.selenium.core.element.IKeyboardActions; -import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; - /** * @author Wasiq Bhamla * @since 27-Jul-2019 @@ -31,26 +31,26 @@ * @param * @param */ -public abstract class KeyboardAction > extends VerifyElement implements IKeyboardActions { - KeyboardAction (final B browserAction, final By by) { - super (browserAction, by); - } +public abstract class KeyboardAction> + extends VerifyElement implements IKeyboardActions { + KeyboardAction (final B browserAction, final By by, final String name) { + super (browserAction, by, name); + } - KeyboardAction (final B browserAction, final By by, final WaitStrategy strategy) { - super (browserAction, by, strategy); - } + KeyboardAction (final B browserAction, final By by, final String name, final WaitStrategy strategy) { + super (browserAction, by, name, strategy); + } - KeyboardAction (final B browserAction, final E element) { - super (browserAction, element); - } + KeyboardAction (final B browserAction, final E element, final String name) { + super (browserAction, element, name); + } - KeyboardAction (final B browserAction, final E element, final WaitStrategy strategy) { - super (browserAction, element, strategy); - } + KeyboardAction (final B browserAction, final E element, final String name, final WaitStrategy strategy) { + super (browserAction, element, name, strategy); + } - @Override - public void pressKey (final Keys... keys) { - perform (e -> e.sendKeys (keys)); - } + @Override + public void pressKey (final Keys... keys) { + perform (e -> e.sendKeys (keys)); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/VerifyElement.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/VerifyElement.java index 03560b6..ae29de2 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/VerifyElement.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/element/VerifyElement.java @@ -18,16 +18,16 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; import com.github.wasiqb.coteafs.selenium.core.element.IVerifyElement; import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; import com.google.common.truth.BooleanSubject; import com.google.common.truth.StringSubject; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 @@ -35,46 +35,46 @@ * @param * @param */ -public class VerifyElement > - extends ElementAction implements IVerifyElement { - VerifyElement (final B browserAction, final By by) { - super (browserAction, by); - } +public class VerifyElement> + extends ElementAction implements IVerifyElement { + VerifyElement (final B browserAction, final By by, final String name) { + super (browserAction, by, name); + } - VerifyElement (final B browserAction, final By by, final WaitStrategy strategy) { - super (browserAction, by, strategy); - } + VerifyElement (final B browserAction, final By by, final String name, final WaitStrategy strategy) { + super (browserAction, by, name, strategy); + } - VerifyElement (final B browserAction, final E element) { - super (browserAction, element); - } + VerifyElement (final B browserAction, final E element, final String name) { + super (browserAction, element, name); + } - VerifyElement (final B browserAction, final E element, final WaitStrategy strategy) { - super (browserAction, element, strategy); - } + VerifyElement (final B browserAction, final E element, final String name, final WaitStrategy strategy) { + super (browserAction, element, name, strategy); + } - @Override - public StringSubject verifyAttribute (final String attribute) { - return assertThat (attribute (attribute)); - } + @Override + public StringSubject verifyAttribute (final String attribute) { + return assertThat (attribute (attribute)); + } - @Override - public BooleanSubject verifyDisplayed () { - return assertWithMessage ("Is Displayed?").that (isDisplayed ()); - } + @Override + public BooleanSubject verifyDisplayed () { + return assertWithMessage ("Is Displayed?").that (isDisplayed ()); + } - @Override - public BooleanSubject verifyEnabled () { - return assertWithMessage ("Is Enabled?").that (isEnabled ()); - } + @Override + public BooleanSubject verifyEnabled () { + return assertWithMessage ("Is Enabled?").that (isEnabled ()); + } - @Override - public BooleanSubject verifySelected () { - return assertWithMessage ("Is Selected?").that (isSelected ()); - } + @Override + public BooleanSubject verifySelected () { + return assertWithMessage ("Is Selected?").that (isSelected ()); + } - @Override - public StringSubject verifyText () { - return assertThat (text ()); - } + @Override + public StringSubject verifyText () { + return assertThat (text ()); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IAlertAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IAlertAction.java index 64bc854..49571f9 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IAlertAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IAlertAction.java @@ -23,21 +23,19 @@ * @since 03-Jul-2019 */ public interface IAlertAction { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @param decision - * alert decision - * @return message - */ - String alert (AlertDecision decision); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @param decision alert decision + * @return message + */ + String alert (AlertDecision decision); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @param decision - * alert decision - * @return string subject - */ - StringSubject verifyAlertMessage (AlertDecision decision); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @param decision alert decision + * @return string subject + */ + StringSubject verifyAlertMessage (AlertDecision decision); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriver.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriver.java index bdba19e..973b880 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriver.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriver.java @@ -15,36 +15,35 @@ */ package com.github.wasiqb.coteafs.selenium.core.driver; -import org.openqa.selenium.WebDriver; - import com.github.wasiqb.coteafs.selenium.core.enums.ApplicationType; +import org.openqa.selenium.WebDriver; + /** * @author Wasiq Bhamla * @param * @since 06-Jun-2019 */ -public interface IDriver extends IServiceAction, IPlatformAction { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @return application type. - */ - ApplicationType getApplicationType (); +public interface IDriver extends IServiceAction, IPlatformAction { + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @return application type. + */ + ApplicationType getApplicationType (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @return driver - */ - D getDriver (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @return driver + */ + D getDriver (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @param - * driver action - * @return actions - */ - > T perform (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @param driver action + * @return actions + */ + > T perform (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriverActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriverActions.java index 8075e56..ce73bbf 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriverActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IDriverActions.java @@ -15,28 +15,26 @@ */ package com.github.wasiqb.coteafs.selenium.core.driver; -import org.openqa.selenium.WebDriver; - import com.google.common.truth.StringSubject; +import org.openqa.selenium.WebDriver; /** - * @author Wasiq Bhamla * @param + * @author Wasiq Bhamla * @since 06-Jun-2019 */ -public interface IDriverActions - extends IScriptAction, IAlertAction, IScreenAction, IWaitAction { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @return title - */ - String title (); +public interface IDriverActions extends IScriptAction, IScreenAction, IWaitAction { + /** + * @return title + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + String title (); - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @return string subject - */ - StringSubject verifyTitle (); + /** + * @return string subject + * @author Wasiq Bhamla + * @since 08-Jun-2019 + */ + StringSubject verifyTitle (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IPlatformAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IPlatformAction.java index d880686..85245d9 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IPlatformAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IPlatformAction.java @@ -23,17 +23,17 @@ * @since 03-Jul-2019 */ public interface IPlatformAction { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @return platform - */ - Platform getPlatform (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @return platform + */ + Platform getPlatform (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @return platform os. - */ - PlatformOs getPlatformOs (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @return platform os. + */ + PlatformOs getPlatformOs (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScreenAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScreenAction.java index 2f0429e..07699dd 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScreenAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScreenAction.java @@ -15,28 +15,44 @@ */ package com.github.wasiqb.coteafs.selenium.core.driver; +import java.io.File; + /** * @author Wasiq Bhamla * @since 03-Jul-2019 */ public interface IScreenAction { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @return screenshot - */ - byte [] attachScreenshot (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @return screenshot + */ + byte [] attachScreenshot (); + + /** + * @author Wasiq Bhamla + * @return file + * @since 25-Jul-2019 + */ + File saveScreenshot (); + + /** + * @author Wasiq Bhamla + * @param path + * @return file + * @since 25-Jul-2019 + */ + File saveScreenshot (String path); - /** - * @author Wasiq Bhamla - * @since 25-Jul-2019 - */ - void saveScreenshot (); + /** + * @author Wasiq Bhamla + * @since 27-Oct-2019 + */ + void startRecording (); - /** - * @author Wasiq Bhamla - * @param path - * @since 25-Jul-2019 - */ - void saveScreenshot (String path); + /** + * @author Wasiq Bhamla + * @since 27-Oct-2019 + */ + void stopRecording (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScriptAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScriptAction.java index be54b4c..5587bde 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScriptAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IScriptAction.java @@ -20,16 +20,13 @@ * @since 03-Jul-2019 */ public interface IScriptAction { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @param - * output type - * @param script - * script - * @param args - * args - * @return result - */ - T execute (final String script, final Object... args); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @param output type + * @param script script + * @param args args + * @return result + */ + T execute (final String script, final Object... args); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IServiceAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IServiceAction.java index a6e45cf..1dd2d6b 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IServiceAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IServiceAction.java @@ -20,22 +20,22 @@ * @since 03-Jul-2019 */ public interface IServiceAction { - /** - * @author Wasiq Bhamla - * @since 24-Jul-2019 - * @return is running - */ - boolean isRunning (); + /** + * @author Wasiq Bhamla + * @since 24-Jul-2019 + * @return is running + */ + boolean isRunning (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - */ - void start (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + void start (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - */ - void stop (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + void stop (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWaitAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWaitAction.java index e9264a8..1a46785 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWaitAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWaitAction.java @@ -23,18 +23,18 @@ * @param * @since 27-Jul-2019 */ -public interface IWaitAction { - /** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @return driver - */ - D driver (); +public interface IWaitAction { + /** + * @author Wasiq Bhamla + * @since 27-Jul-2019 + * @return driver + */ + D driver (); - /** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @return wait - */ - WebDriverWait driverWait (); + /** + * @author Wasiq Bhamla + * @since 27-Jul-2019 + * @return wait + */ + WebDriverWait driverWait (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriver.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriver.java index 666c55a..9c9a093 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriver.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriver.java @@ -21,12 +21,11 @@ * @author Wasiq Bhamla * @since 06-Jun-2019 */ -public interface IWebDriver extends IDriver { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @param browser - * Browser under test - */ - void setBrowserUnderTest (String browser); +public interface IWebDriver extends IDriver { + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @param browser Browser under test + */ + void setBrowserUnderTest (String browser); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriverActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriverActions.java index 840d9d3..ac27504 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriverActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebDriverActions.java @@ -20,39 +20,37 @@ /** * @author Wasiq Bhamla * @since 06-Jun-2019 - * @param - * Driver + * @param Driver */ -public interface IWebDriverActions extends IDriverActions { - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - */ - void back (); +public interface IWebDriverActions extends IDriverActions { + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + void back (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - */ - void deleteCookies (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + void deleteCookies (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - */ - void forward (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + void forward (); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - * @param url - * URL - */ - void navigateTo (String url); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + * @param url URL + */ + void navigateTo (String url); - /** - * @author Wasiq Bhamla - * @since 06-Jun-2019 - */ - void refresh (); + /** + * @author Wasiq Bhamla + * @since 06-Jun-2019 + */ + void refresh (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebFrame.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebFrame.java index 85ebe21..76339b9 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebFrame.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebFrame.java @@ -20,25 +20,23 @@ * @since 06-Jul-2019 */ public interface IWebFrame { - /** - * @author Wasiq Bhamla - * @since 06-Jul-2019 - */ - void switchFrame (); + /** + * @author Wasiq Bhamla + * @since 06-Jul-2019 + */ + void switchFrame (); - /** - * @author Wasiq Bhamla - * @since 06-Jul-2019 - * @param index - * frame index - */ - void switchFrame (int index); + /** + * @author Wasiq Bhamla + * @since 06-Jul-2019 + * @param index frame index + */ + void switchFrame (int index); - /** - * @author Wasiq Bhamla - * @since 06-Jul-2019 - * @param nameOrId - * frame name or id - */ - void switchFrame (String nameOrId); + /** + * @author Wasiq Bhamla + * @since 06-Jul-2019 + * @param nameOrId frame name or id + */ + void switchFrame (String nameOrId); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebWindow.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebWindow.java index 6485458..bb64470 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebWindow.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/driver/IWebWindow.java @@ -20,17 +20,16 @@ * @since 16-Jun-2019 */ public interface IWebWindow { - /** - * @author Wasiq Bhamla - * @since 16-Jun-2019 - */ - void switchWindow (); + /** + * @author Wasiq Bhamla + * @since 16-Jun-2019 + */ + void switchWindow (); - /** - * @author Wasiq Bhamla - * @since 16-Jun-2019 - * @param title - * window title - */ - void switchWindow (String title); + /** + * @author Wasiq Bhamla + * @since 16-Jun-2019 + * @param title window title + */ + void switchWindow (String title); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IElementActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IElementActions.java index dd77f6d..c1c6526 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IElementActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IElementActions.java @@ -20,46 +20,45 @@ * @since 07-Jun-2019 */ public interface IElementActions extends IWaitStrategy { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param name - * attribute name - * @return attribute - */ - String attribute (String name); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param name attribute name + * @return attribute + */ + String attribute (String name); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void clear (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void clear (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return is displayed - */ - boolean isDisplayed (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return is displayed + */ + boolean isDisplayed (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return is enabled - */ - boolean isEnabled (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return is enabled + */ + boolean isEnabled (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return is selected - */ - boolean isSelected (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return is selected + */ + boolean isSelected (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return text - */ - String text (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return text + */ + String text (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IFindableAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IFindableAction.java index 4e57b59..afd3ec7 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IFindableAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IFindableAction.java @@ -17,52 +17,54 @@ import java.util.List; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.enums.WaitStrategy; +import org.openqa.selenium.By; + /** * @author Wasiq Bhamla * @since 27-Jul-2019 */ public interface IFindableAction extends IKeyboardActions { - /** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @param byLocator - * locator - * @return actions - */ - E find (final By byLocator); + /** + * @author Wasiq Bhamla + * @param + * @since 27-Jul-2019 + * @param byLocator locator + * @param name + * @return actions + */ + E find (final By byLocator, final String name); - /** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @param byLocator - * locator - * @param strategy - * wait strategy - * @return list of actions - */ - E find (final By byLocator, WaitStrategy strategy); + /** + * @author Wasiq Bhamla + * @param + * @since 27-Jul-2019 + * @param byLocator locator + * @param name + * @param strategy wait strategy + * @return list of actions + */ + E find (final By byLocator, final String name, WaitStrategy strategy); - /** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @param byLocator - * locator - * @return list of actions - */ - List finds (final By byLocator); + /** + * @author Wasiq Bhamla + * @param + * @since 27-Jul-2019 + * @param byLocator locator + * @param name + * @return list of actions + */ + List finds (final By byLocator, final String name); - /** - * @author Wasiq Bhamla - * @since 27-Jul-2019 - * @param byLocator - * locator - * @param strategy - * wait strategy - * @return list of actions - */ - List finds (final By byLocator, WaitStrategy strategy); + /** + * @author Wasiq Bhamla + * @param + * @since 27-Jul-2019 + * @param byLocator locator + * @param name + * @param strategy wait strategy + * @return list of actions + */ + List finds (final By byLocator, final String name, WaitStrategy strategy); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IKeyboardActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IKeyboardActions.java index 3f13f06..0905dc2 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IKeyboardActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IKeyboardActions.java @@ -22,11 +22,10 @@ * @since 08-Jun-2019 */ public interface IKeyboardActions extends IVerifyElement { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param keys - * Keys - */ - void pressKey (Keys... keys); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param keys Keys + */ + void pressKey (Keys... keys); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IMouseActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IMouseActions.java index fd80511..4c1b314 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IMouseActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IMouseActions.java @@ -20,15 +20,15 @@ * @since 07-Jun-2019 */ public interface IMouseActions extends IFindableAction { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void click (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void click (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void hover (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void hover (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ISelectboxActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ISelectboxActions.java index 276bf60..0290c2f 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ISelectboxActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ISelectboxActions.java @@ -22,78 +22,72 @@ * @since 07-Jun-2019 */ public interface ISelectboxActions extends IMouseActions { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void deselectAll (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void deselectAll (); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param index - * item indoex - */ - void deselectByIndex (int index); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @param index item indoex + */ + void deselectByIndex (int index); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param value - * item value - */ - void deselectByText (String value); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param value item value + */ + void deselectByText (String value); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param value - * item value - */ - void deselectByValue (String value); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @param value item value + */ + void deselectByValue (String value); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @return is multi select - */ - boolean isMultiSelect (); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @return is multi select + */ + boolean isMultiSelect (); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @return all options - */ - List options (); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @return all options + */ + List options (); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param index - * item indoex - */ - void selectByIndex (int index); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @param index item indoex + */ + void selectByIndex (int index); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param value - * item value - */ - void selectByText (String value); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param value item value + */ + void selectByText (String value); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param value - * item value - */ - void selectByValue (String value); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @param value item value + */ + void selectByValue (String value); - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @return all selected options - */ - List selectedOptions (); + /** + * @author Wasiq Bhamla + * @since 12-Jul-2019 + * @return all selected options + */ + List selectedOptions (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ITextboxActions.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ITextboxActions.java index 4ef90f4..2a83459 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ITextboxActions.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/ITextboxActions.java @@ -20,11 +20,10 @@ * @since 07-Jun-2019 */ public interface ITextboxActions extends IMouseActions { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param text - * input text - */ - void enterText (String text); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param text input text + */ + void enterText (String text); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IVerifyElement.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IVerifyElement.java index 9f1bae8..a73b8ef 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IVerifyElement.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IVerifyElement.java @@ -23,40 +23,39 @@ * @since 07-Jun-2019 */ public interface IVerifyElement extends IElementActions { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param attribute - * element attribute - * @return subject - */ - StringSubject verifyAttribute (final String attribute); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param attribute element attribute + * @return subject + */ + StringSubject verifyAttribute (final String attribute); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return subject - */ - BooleanSubject verifyDisplayed (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return subject + */ + BooleanSubject verifyDisplayed (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return subject - */ - BooleanSubject verifyEnabled (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return subject + */ + BooleanSubject verifyEnabled (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return subject - */ - BooleanSubject verifySelected (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return subject + */ + BooleanSubject verifySelected (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @return subject - */ - StringSubject verifyText (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @return subject + */ + StringSubject verifyText (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IWaitStrategy.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IWaitStrategy.java index 7d19dc4..fd31741 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IWaitStrategy.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/element/IWaitStrategy.java @@ -20,31 +20,29 @@ * @since 07-Jun-2019 */ public interface IWaitStrategy { - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - * @param attribute - * element attribute - * @param value - * attribute value - */ - void waitUntilAttributeIs (final String attribute, final String value); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + * @param attribute element attribute + * @param value attribute value + */ + void waitUntilAttributeIs (final String attribute, final String value); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void waitUntilClickable (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void waitUntilClickable (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void waitUntilInvisible (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void waitUntilInvisible (); - /** - * @author Wasiq Bhamla - * @since 07-Jun-2019 - */ - void waitUntilVisible (); + /** + * @author Wasiq Bhamla + * @since 07-Jun-2019 + */ + void waitUntilVisible (); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AlertDecision.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AlertDecision.java index e83c4f1..50848f6 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AlertDecision.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AlertDecision.java @@ -20,12 +20,12 @@ * @since 06-Jun-2019 */ public enum AlertDecision { - /** - * Accept alert. - */ - ACCEPT, - /** - * Dismiss alert. - */ - DISMISS + /** + * Accept alert. + */ + ACCEPT, + /** + * Dismiss alert. + */ + DISMISS } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ApplicationType.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ApplicationType.java index f073fd7..5219a4a 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ApplicationType.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ApplicationType.java @@ -20,16 +20,16 @@ * @since 06-Jun-2019 */ public enum ApplicationType { - /** - * Hybrid app. - */ - HYBRID, - /** - * Native app. - */ - NATIVE, - /** - * Web app. - */ - WEB + /** + * Hybrid app. + */ + HYBRID, + /** + * Native app. + */ + NATIVE, + /** + * Web app. + */ + WEB } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AvailableBrowser.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AvailableBrowser.java index ab2cd6e..3a9e9f0 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AvailableBrowser.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/AvailableBrowser.java @@ -20,28 +20,28 @@ * @since Apr 8, 2018 2:42:01 PM */ public enum AvailableBrowser { - /** - * Chrome. - */ - CHROME, - /** - * Edge. - */ - EDGE, - /** - * Firefox. - */ - FIREFOX, - /** - * IE. - */ - IE, - /** - * Safari. - */ - SAFARI, - /** - * Remote Grid or Cloud instance. - */ - REMOTE + /** + * Chrome. + */ + CHROME, + /** + * Edge. + */ + EDGE, + /** + * Firefox. + */ + FIREFOX, + /** + * IE. + */ + IE, + /** + * Remote Grid or Cloud instance. + */ + REMOTE, + /** + * Safari. + */ + SAFARI } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Platform.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Platform.java index 845ffd8..a3173b8 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Platform.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Platform.java @@ -20,24 +20,24 @@ * @since 06-Jun-2019 */ public enum Platform { - /** - * Desktop. - */ - DESKTOP, - /** - * Mobiles. - */ - MOBILE, - /** - * Tablets. - */ - TABLET, - /** - * Smart TV. - */ - TV, - /** - * Smart watch. - */ - WATCH + /** + * Desktop. + */ + DESKTOP, + /** + * Mobiles. + */ + MOBILE, + /** + * Tablets. + */ + TABLET, + /** + * Smart TV. + */ + TV, + /** + * Smart watch. + */ + WATCH } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/PlatformOs.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/PlatformOs.java index a4039f8..d6576ce 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/PlatformOs.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/PlatformOs.java @@ -20,28 +20,28 @@ * @since 06-Jun-2019 */ public enum PlatformOs { - /** - * Android. - */ - ANDROID, - /** - * iOS. - */ - IOS, - /** - * Linux. - */ - LINUX, - /** - * Mac OSX. - */ - MAC, - /** - * tvOS. - */ - TV_OS, - /** - * Windows. - */ - WINDOWS + /** + * Android. + */ + ANDROID, + /** + * iOS. + */ + IOS, + /** + * Linux. + */ + LINUX, + /** + * Mac OSX. + */ + MAC, + /** + * tvOS. + */ + TV_OS, + /** + * Windows. + */ + WINDOWS } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Protocol.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Protocol.java index 6ddeb2b..6092dfb 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Protocol.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/Protocol.java @@ -20,27 +20,27 @@ * @since 01-Aug-2019 */ public enum Protocol { - /** - * http - */ - HTTP ("http://"), - /** - * https - */ - HTTPS ("https://"); + /** + * http + */ + HTTP ("http://"), + /** + * https + */ + HTTPS ("https://"); - private final String prefix; + private final String prefix; - Protocol (final String prefix) { - this.prefix = prefix; - } + Protocol (final String prefix) { + this.prefix = prefix; + } - /** - * @author Wasiq Bhamla - * @since 01-Aug-2019 - * @return prefix - */ - public String getPrefix () { - return this.prefix; - } + /** + * @author Wasiq Bhamla + * @since 01-Aug-2019 + * @return prefix + */ + public String getPrefix () { + return this.prefix; + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/RemoteSource.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/RemoteSource.java index eae4c47..c65bcfe 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/RemoteSource.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/RemoteSource.java @@ -20,16 +20,16 @@ * @since 01-Aug-2019 */ public enum RemoteSource { - /** - * BrowserStack. - */ - BROWSERSTACK, - /** - * Grid. - */ - GRID, - /** - * SauceLabs. - */ - SAUCELABS + /** + * BrowserStack. + */ + BROWSERSTACK, + /** + * Grid. + */ + GRID, + /** + * SauceLabs. + */ + SAUCELABS } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ScreenState.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ScreenState.java index 37d436e..86993f6 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ScreenState.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/ScreenState.java @@ -20,16 +20,16 @@ * @since Apr 8, 2018 2:46:38 PM */ public enum ScreenState { - /** - * Full screen. - */ - FULL_SCREEN, - /** - * Maximized. - */ - MAXIMIZED, - /** - * Normal. - */ - NORMAL + /** + * Full screen. + */ + FULL_SCREEN, + /** + * Maximized. + */ + MAXIMIZED, + /** + * Normal. + */ + NORMAL } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/WaitStrategy.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/WaitStrategy.java index e60135e..fe85611 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/WaitStrategy.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/enums/WaitStrategy.java @@ -20,20 +20,20 @@ * @since 09-Jun-2019 */ public enum WaitStrategy { - /** - * Wait until clickable. - */ - CLICKABLE, - /** - * Wait until invisible. - */ - INVISIBLE, - /** - * None. - */ - NONE, - /** - * Wait until visible. - */ - VISIBLE + /** + * Wait until clickable. + */ + CLICKABLE, + /** + * Wait until invisible. + */ + INVISIBLE, + /** + * None. + */ + NONE, + /** + * Wait until visible. + */ + VISIBLE } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/AbstractPageAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/AbstractPageAction.java index 954dba9..448450e 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/AbstractPageAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/AbstractPageAction.java @@ -15,34 +15,23 @@ */ package com.github.wasiqb.coteafs.selenium.core.page; -import java.util.HashMap; -import java.util.Map; +import static com.github.wasiqb.coteafs.selenium.core.base.driver.ParallelSession.getSession; /** * @author wasiqb * @param * @since Sep 1, 2018 4:28:28 PM */ -@SuppressWarnings ("unchecked") -public abstract class AbstractPageAction > implements IPageAction { - private final Map values; +public abstract class AbstractPageAction> implements IPageAction { + @SuppressWarnings ("unchecked") + @Override + public T addInputValue (final String element, final Object value) { + getSession ().setContext (element, value); + return (T) this; + } - /** - * @author wasiqb - * @since Sep 1, 2018 8:04:10 PM - */ - public AbstractPageAction () { - this.values = new HashMap <> (); - } - - @Override - public T addInputValue (final String element, final Object value) { - this.values.put (element, value); - return (T) this; - } - - @Override - public E value (final String element) { - return (E) this.values.get (element); - } + @Override + public E value (final String element) { + return getSession ().getContext (element); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPage.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPage.java index 7e88271..72ef6bf 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPage.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPage.java @@ -15,16 +15,16 @@ */ package com.github.wasiqb.coteafs.selenium.core.page; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; 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 org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + /** * @author Wasiq Bhamla * @param @@ -32,131 +32,146 @@ * @param * @since 08-Jun-2019 */ -public interface IPage , E extends WebElement> { - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param locator - * locator - * @return element action - */ - T onClickable (By locator); - - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param locator - * locator - * @param strategy - * strategy - * @return element action - */ - T onClickable (By locator, WaitStrategy strategy); - - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param element - * element - * @return element action - */ - T onClickable (E element); - - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param element - * element - * @param strategy - * wait strategy - * @return element action - */ - T onClickable (E element, WaitStrategy strategy); - - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @return driver action - */ - B onDriver (); - - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param locator - * locator - * @return element action - */ - T onDropdown (By locator); - - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param locator - * locator - * @param strategy - * strategy - * @return element action - */ - T onDropdown (By locator, WaitStrategy strategy); - - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param element - * element - * @return element action - */ - T onDropdown (E element); - - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param element - * element - * @param strategy - * strategy - * @return element action - */ - T onDropdown (E element, WaitStrategy strategy); - - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param locator - * locator - * @return element action - */ - T onTextbox (By locator); - - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param locator - * locator - * @param strategy - * strategy - * @return element action - */ - T onTextbox (By locator, WaitStrategy strategy); - - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param element - * element - * @return element action - */ - T onTextbox (E element); - - /** - * @author Wasiq Bhamla - * @since 12-Jul-2019 - * @param element - * element - * @param strategy - * strategy - * @return element action - */ - T onTextbox (E element, WaitStrategy strategy); +public interface IPage, E extends WebElement> { + /** + * @author Wasiq Bhamla + * @since 14-Oct-2019 + * @param + * @param pageCls + * @return next page instance + */ + > T nextPage (Class pageCls); + + /** + * @author Wasiq Bhamla + * @param + * @since 08-Jun-2019 + * @param locator locator + * @param name + * @return element action + */ + T onClickable (By locator, final String name); + + /** + * @author Wasiq Bhamla + * @param + * @since 12-Jul-2019 + * @param locator locator + * @param name + * @param strategy strategy + * @return element action + */ + T onClickable (By locator, final String name, WaitStrategy strategy); + + /** + * @author Wasiq Bhamla + * @param + * @since 08-Jun-2019 + * @param element element + * @param name + * @return element action + */ + T onClickable (E element, final String name); + + /** + * @author Wasiq Bhamla + * @param + * @since 12-Jul-2019 + * @param element element + * @param name + * @param strategy wait strategy + * @return element action + */ + T onClickable (E element, final String name, WaitStrategy strategy); + + /** + * @author Wasiq Bhamla + * @since 08-Jun-2019 + * @return driver action + */ + B onDriver (); + + /** + * @author Wasiq Bhamla + * @param + * @since 08-Jun-2019 + * @param locator locator + * @param name + * @return element action + */ + T onDropdown (By locator, final String name); + + /** + * @author Wasiq Bhamla + * @param + * @since 12-Jul-2019 + * @param locator locator + * @param name + * @param strategy strategy + * @return element action + */ + T onDropdown (By locator, final String name, WaitStrategy strategy); + + /** + * @author Wasiq Bhamla + * @param + * @since 08-Jun-2019 + * @param element element + * @param name + * @return element action + */ + T onDropdown (E element, final String name); + + /** + * @author Wasiq Bhamla + * @param + * @since 12-Jul-2019 + * @param element element + * @param name + * @param strategy strategy + * @return element action + */ + T onDropdown (E element, final String name, WaitStrategy strategy); + + /** + * @author Wasiq Bhamla + * @param + * @since 08-Jun-2019 + * @param locator locator + * @param name + * @return element action + */ + T onTextbox (By locator, final String name); + + /** + * @author Wasiq Bhamla + * @param + * @since 12-Jul-2019 + * @param locator locator + * @param name + * @param strategy strategy + * @return element action + */ + T onTextbox (By locator, final String name, WaitStrategy strategy); + + /** + * @author Wasiq Bhamla + * @param + * @since 08-Jun-2019 + * @param element element + * @param name + * @return element action + */ + T onTextbox (E element, final String name); + + /** + * @author Wasiq Bhamla + * @param + * @since 12-Jul-2019 + * @param element element + * @param name + * @param strategy strategy + * @return element action + */ + T onTextbox (E element, final String name, WaitStrategy strategy); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPageAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPageAction.java index d2747c5..3027933 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPageAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/core/page/IPageAction.java @@ -20,33 +20,28 @@ * @since 08-Jun-2019 */ public interface IPageAction { - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param - * page action - * @param element - * element alias - * @param value - * element input value - * @return page action - */ - T addInputValue (final String element, final Object value); + /** + * @author Wasiq Bhamla + * @since 08-Jun-2019 + * @param page action + * @param element element alias + * @param value element input value + * @return page action + */ + T addInputValue (final String element, final Object value); - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - */ - void perform (); + /** + * @author Wasiq Bhamla + * @since 08-Jun-2019 + */ + void perform (); - /** - * @author Wasiq Bhamla - * @since 08-Jun-2019 - * @param - * input value - * @param element - * element alias - * @return input value - */ - T value (final String element); + /** + * @author Wasiq Bhamla + * @since 08-Jun-2019 + * @param input value + * @param element element alias + * @return input value + */ + T value (final String element); } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/error/DriverNotSetupError.java b/src/main/java/com/github/wasiqb/coteafs/selenium/error/DriverNotSetupError.java index e679e43..4365cd3 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/error/DriverNotSetupError.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/error/DriverNotSetupError.java @@ -25,14 +25,14 @@ * @since 03-Aug-2019 */ public class DriverNotSetupError extends CoteafsError { - private static final long serialVersionUID = -8652506910306288004L; + private static final long serialVersionUID = -8652506910306288004L; - /** - * @author Wasiq Bhamla - * @since 03-Aug-2019 - * @param message - */ - public DriverNotSetupError (final String message) { - super (message, Reason.R1, Category.C1, Severity.HIGH); - } + /** + * @author Wasiq Bhamla + * @since 03-Aug-2019 + * @param message + */ + public DriverNotSetupError (final String message) { + super (message, Reason.R1, Category.C1, Severity.HIGH); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriverAction.java b/src/main/java/com/github/wasiqb/coteafs/selenium/error/VideoRecordingError.java similarity index 50% rename from src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriverAction.java rename to src/main/java/com/github/wasiqb/coteafs/selenium/error/VideoRecordingError.java index fa39b5a..125a14a 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/core/base/driver/AbstractDriverAction.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/error/VideoRecordingError.java @@ -13,33 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.github.wasiqb.coteafs.selenium.core.base.driver; +package com.github.wasiqb.coteafs.selenium.error; -import static com.google.common.truth.Truth.assertThat; - -import org.openqa.selenium.WebDriver; - -import com.github.wasiqb.coteafs.selenium.core.driver.IDriverActions; -import com.google.common.truth.StringSubject; +import com.github.wasiqb.coteafs.error.CoteafsError; /** * @author Wasiq Bhamla - * @since 26-Jul-2019 - * @param + * @since 28-Nov-2019 */ -public class AbstractDriverAction extends AlertAction - implements IDriverActions { - AbstractDriverAction (final D driver) { - super (driver); - } - - @Override - public String title () { - return get (WebDriver::getTitle); - } +public class VideoRecordingError extends CoteafsError { + private static final long serialVersionUID = 6184267334962964373L; - @Override - public StringSubject verifyTitle () { - return assertThat (title ()); - } -} + /** + * @author Wasiq Bhamla + * @since 28-Nov-2019 + */ + public VideoRecordingError (final String message, final Throwable cause) { + super (message, cause); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/listeners/DriverListner.java b/src/main/java/com/github/wasiqb/coteafs/selenium/listeners/DriverListner.java index 9deaa74..254e5c3 100644 --- a/src/main/java/com/github/wasiqb/coteafs/selenium/listeners/DriverListner.java +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/listeners/DriverListner.java @@ -15,8 +15,10 @@ */ package com.github.wasiqb.coteafs.selenium.listeners; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import static java.util.Arrays.stream; + +import com.github.wasiqb.coteafs.logger.Loggy; + import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.WebDriver; @@ -28,152 +30,160 @@ * @since Apr 28, 2019 */ public class DriverListner implements WebDriverEventListener { - private static final Logger LOG = LogManager.getLogger (DriverListner.class); - - @Override - public void afterAlertAccept (final WebDriver driver) { - LOG.trace ("Alert dialog accepted..."); - } - - @Override - public void afterAlertDismiss (final WebDriver driver) { - LOG.trace ("Alert dialog dismissed..."); - } - - @Override - public void afterChangeValueOf (final WebElement element, final WebDriver driver, - final CharSequence [] keysToSend) { - if (keysToSend != null) { - final String message = "Text {} has been entered..."; - LOG.trace (message, (Object) keysToSend); - } - } - - @Override - public void afterClickOn (final WebElement element, final WebDriver driver) { - LOG.trace ("Clicked on element..."); - } - - @Override - public void afterFindBy (final By by, final WebElement element, final WebDriver driver) { - LOG.trace ("Element found using {}...", by); - } - - @Override - public void afterGetScreenshotAs (final OutputType target, final X screenshot) { - LOG.trace ("Taken screenshot successfully..."); - } - - @Override - public void afterGetText (final WebElement element, final WebDriver driver, final String text) { - LOG.trace ("Got text {} from element...", text); - } - - @Override - public void afterNavigateBack (final WebDriver driver) { - LOG.trace ("Navigated backward..."); - } - - @Override - public void afterNavigateForward (final WebDriver driver) { - LOG.trace ("Navigated forward..."); - } - - @Override - public void afterNavigateRefresh (final WebDriver driver) { - LOG.trace ("Page refreshed..."); - } - - @Override - public void afterNavigateTo (final String url, final WebDriver driver) { - LOG.trace ("Navigated to url {}...", url); - } - - @Override - public void afterScript (final String script, final WebDriver driver) { - LOG.trace ("Script {} executed successfully...", script); - } - - @Override - public void afterSwitchToWindow (final String windowName, final WebDriver driver) { - LOG.trace ("Window switched to {}...", windowName); - } - - @Override - public void beforeAlertAccept (final WebDriver driver) { - LOG.info ("Accepting Alert pop-up..."); - } - - @Override - public void beforeAlertDismiss (final WebDriver driver) { - LOG.info ("Dismissing Alert pop-up..."); - } - - @Override - public void beforeChangeValueOf (final WebElement element, final WebDriver driver, - final CharSequence [] keysToSend) { - if (keysToSend != null) { - LOG.info ("Writing text {}...", (Object) keysToSend); - } - } - - @Override - public void beforeClickOn (final WebElement element, final WebDriver driver) { - LOG.info ("Clicking on Element..."); - } - - @Override - public void beforeFindBy (final By by, final WebElement element, final WebDriver driver) { - LOG.trace ("Finding element by {}", by); - } - - @Override - public void beforeGetScreenshotAs (final OutputType target) { - LOG.trace ("Taking screenshot..."); - } - - @Override - public void beforeGetText (final WebElement element, final WebDriver driver) { - LOG.trace ("Getting text from element..."); - } - - @Override - public void beforeNavigateBack (final WebDriver driver) { - LOG.info ("Navigating back..."); - } - - @Override - public void beforeNavigateForward (final WebDriver driver) { - LOG.info ("Navigating forward..."); - } - - @Override - public void beforeNavigateRefresh (final WebDriver driver) { - LOG.info ("Refreshing the page..."); - } - - @Override - public void beforeNavigateTo (final String url, final WebDriver driver) { - LOG.info ("Navigating to {}...", url); - } - - @Override - public void beforeScript (final String script, final WebDriver driver) { - final String message = "Executing script {}..."; - LOG.trace (message, script); - } - - @Override - public void beforeSwitchToWindow (final String windowName, final WebDriver driver) { - LOG.info ("Switching to window {}...", windowName); - } - - @Override - public void onException (final Throwable throwable, final WebDriver driver) { - LOG.error ("Error occurred: {}", throwable.getMessage ()); - for (final StackTraceElement stack : throwable.getStackTrace ()) { - LOG.error ("\tat: {}", stack); - } - LOG.catching (throwable); - } + private static final Loggy LOG = Loggy.init (); + private static String name; + + /** + * @author Wasiq Bhamla + * @since 25-Sep-2019 + * @param alias the Element alias to set + */ + public static void setAlias (final String alias) { + name = alias; + } + + @Override + public void afterAlertAccept (final WebDriver driver) { + LOG.t ("Alert dialog accepted with message [{}]...", name); + } + + @Override + public void afterAlertDismiss (final WebDriver driver) { + LOG.t ("Alert dialog dismissed [{}]...", name); + } + + @Override + public void afterChangeValueOf (final WebElement element, final WebDriver driver, + final CharSequence [] keysToSend) { + if (keysToSend != null) { + final String message = "Text {} has been entered in element [{}]..."; + LOG.t (message, keysToSend, name); + } + } + + @Override + public void afterClickOn (final WebElement element, final WebDriver driver) { + LOG.t ("Clicked on element [{}]...", name); + } + + @Override + public void afterFindBy (final By by, final WebElement element, final WebDriver driver) { + LOG.t ("Element [{}] found using {}...", name, by); + } + + @Override + public void afterGetScreenshotAs (final OutputType target, final X screenshot) { + LOG.t ("Taken screenshot successfully..."); + } + + @Override + public void afterGetText (final WebElement element, final WebDriver driver, final String text) { + LOG.t ("Got text {} from element [{}]...", text, name); + } + + @Override + public void afterNavigateBack (final WebDriver driver) { + LOG.t ("Navigated backward..."); + } + + @Override + public void afterNavigateForward (final WebDriver driver) { + LOG.t ("Navigated forward..."); + } + + @Override + public void afterNavigateRefresh (final WebDriver driver) { + LOG.t ("Page refreshed..."); + } + + @Override + public void afterNavigateTo (final String url, final WebDriver driver) { + LOG.t ("Navigated to url {}...", url); + } + + @Override + public void afterScript (final String script, final WebDriver driver) { + LOG.t ("Script {} executed successfully...", script); + } + + @Override + public void afterSwitchToWindow (final String windowName, final WebDriver driver) { + LOG.t ("Window switched to {}...", windowName); + } + + @Override + public void beforeAlertAccept (final WebDriver driver) { + LOG.i ("Accepting Alert pop-up with message [{}]...", name); + } + + @Override + public void beforeAlertDismiss (final WebDriver driver) { + LOG.i ("Dismissing Alert pop-up with message [{}]...", name); + } + + @Override + public void beforeChangeValueOf (final WebElement element, final WebDriver driver, + final CharSequence [] keysToSend) { + if (keysToSend != null) { + LOG.i ("Writing text {} in element [{}]...", keysToSend, name); + } + } + + @Override + public void beforeClickOn (final WebElement element, final WebDriver driver) { + LOG.i ("Clicking on element [{}]...", name); + } + + @Override + public void beforeFindBy (final By by, final WebElement element, final WebDriver driver) { + LOG.t ("Finding element [{}] using {}", name, by); + } + + @Override + public void beforeGetScreenshotAs (final OutputType target) { + LOG.t ("Taking screenshot..."); + } + + @Override + public void beforeGetText (final WebElement element, final WebDriver driver) { + LOG.t ("Getting text from element [{}]...", name); + } + + @Override + public void beforeNavigateBack (final WebDriver driver) { + LOG.i ("Navigating back..."); + } + + @Override + public void beforeNavigateForward (final WebDriver driver) { + LOG.i ("Navigating forward..."); + } + + @Override + public void beforeNavigateRefresh (final WebDriver driver) { + LOG.i ("Refreshing the page..."); + } + + @Override + public void beforeNavigateTo (final String url, final WebDriver driver) { + LOG.i ("Navigating to {}...", url); + } + + @Override + public void beforeScript (final String script, final WebDriver driver) { + final String message = "Executing script {}..."; + LOG.t (message, script); + } + + @Override + public void beforeSwitchToWindow (final String windowName, final WebDriver driver) { + LOG.i ("Switching to window {}...", windowName); + } + + @Override + public void onException (final Throwable throwable, final WebDriver driver) { + LOG.c (throwable); + LOG.e ("Error occurred: {}", throwable.getMessage ()); + stream (throwable.getStackTrace ()).forEach (s -> LOG.e ("\tat: {}", s)); + } } \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/utils/LogLevel.java b/src/main/java/com/github/wasiqb/coteafs/selenium/utils/LogLevel.java new file mode 100644 index 0000000..63bb7dd --- /dev/null +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/utils/LogLevel.java @@ -0,0 +1,51 @@ +/* + * 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.utils; + +/** + * @author Wasiq Bhamla + * @since 26-Oct-2019 + */ +public enum LogLevel { + /** + * Debug. + */ + DEBUG, + /** + * Error. + */ + ERROR, + /** + * Fatal. + */ + FATAL, + /** + * Info. + */ + INFO, + /** + * Trace. + */ + TRACE, + /** + * Unknown. + */ + UNKNOWN, + /** + * Warn. + */ + WARN; +} \ No newline at end of file diff --git a/src/main/java/com/github/wasiqb/coteafs/selenium/utils/ReportPortalLoggy.java b/src/main/java/com/github/wasiqb/coteafs/selenium/utils/ReportPortalLoggy.java new file mode 100644 index 0000000..0e10ce8 --- /dev/null +++ b/src/main/java/com/github/wasiqb/coteafs/selenium/utils/ReportPortalLoggy.java @@ -0,0 +1,42 @@ +package com.github.wasiqb.coteafs.selenium.utils; + +import static com.epam.reportportal.service.ReportPortal.emitLog; +import static java.text.MessageFormat.format; + +import java.io.File; +import java.util.Date; + +/** + * @author Wasiq Bhamla + * @since 29-Oct-2019 + */ +public final class ReportPortalLoggy { + /** + * @author Wasiq Bhamla + * @since 26-Oct-2019 + * @param level + * @param file + * @param message + * @param args + */ + public static void log (final LogLevel level, final File file, final String message, final Object... args) { + emitLog (format (message, args), level.name () + .toLowerCase (), new Date (), file); + } + + /** + * @author Wasiq Bhamla + * @since 26-Oct-2019 + * @param level + * @param message + * @param args + */ + public static void log (final LogLevel level, final String message, final Object... args) { + emitLog (format (message, args), level.name () + .toLowerCase (), new Date ()); + } + + private ReportPortalLoggy () { + // Utility class. + } +} \ No newline at end of file diff --git a/src/main/resources/coteafs-logger.yaml b/src/main/resources/coteafs-logger.yaml deleted file mode 100644 index 68a0c69..0000000 --- a/src/main/resources/coteafs-logger.yaml +++ /dev/null @@ -1,107 +0,0 @@ -status: WARN -monitor_interval: 30 - -properties: - - name: log-path - value: logs - - name: error-log - value: my-log-error - - name: all-log - value: my-log-all - - name: test-log - value: my-log-main - - name: log-pattern - value: "[%d{HH:mm:ss.SSS}] [%-5level] - %msg (%logger{1}:%L) %throwable{short.message}%n" - -appenders: - - name: console-log - plugin: Console - layout: - plugin: PatternLayout - attributes: - pattern: ${log-pattern} - attributes: - target: SYSTEM_OUT - - name: all-log-appender - plugin: RollingFile - attributes: - fileName: ${log-path}/${all-log}.log - filePattern: ${log-path}/${all-log}-%d{yyyy-MM-dd}-%i.log - immediateFlush: true - layout: - plugin: PatternLayout - attributes: - pattern: ${log-pattern} - component: - plugin: Policies - components: - - plugin: TimeBasedTriggeringPolicy - attributes: - interval: 1 - modulate: true - - plugin: SizeBasedTriggeringPolicy - attributes: - size: 5 MB - - plugin: OnStartupTriggeringPolicy - - name: test-log-appender - plugin: RollingFile - attributes: - fileName: ${log-path}/${test-log}.log - filePattern: ${log-path}/${test-log}-%d{yyyy-MM-dd}-%i.log - immediateFlush: true - layout: - plugin: PatternLayout - attributes: - pattern: ${log-pattern} - component: - plugin: Policies - components: - - plugin: TimeBasedTriggeringPolicy - attributes: - interval: 1 - modulate: true - - plugin: SizeBasedTriggeringPolicy - attributes: - size: 5 MB - - plugin: OnStartupTriggeringPolicy - - name: error-log-appender - plugin: RollingFile - attributes: - fileName: ${log-path}/${error-log}.log - filePattern: ${log-path}/${error-log}-%d{yyyy-MM-dd}-%i.log - immediateFlush: true - layout: - plugin: PatternLayout - attributes: - pattern: ${log-pattern} - component: - plugin: Policies - components: - - plugin: TimeBasedTriggeringPolicy - attributes: - interval: 1 - modulate: true - - plugin: SizeBasedTriggeringPolicy - attributes: - size: 5 MB - - plugin: OnStartupTriggeringPolicy - - name: async - plugin: Async - appender_ref: - - ref: "test-log-appender" - -loggers: - level: ALL - appender_ref: - - ref: "console-log" - attributes: - level: DEBUG - - ref: "async" - attributes: - level: INFO - - ref: "all-log-appender" - attributes: - level: TRACE - - ref: "error-log-appender" - attributes: - level: ERROR diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/SeleniumTest.java b/src/test/java/com/github/wasiqb/coteafs/selenium/SeleniumTest.java index 9d7f8b4..fe5de99 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/SeleniumTest.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/SeleniumTest.java @@ -19,9 +19,6 @@ import static com.github.wasiqb.coteafs.selenium.pages.action.LoginPageAction.PASS; import static com.github.wasiqb.coteafs.selenium.pages.action.LoginPageAction.USER_ID; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - import com.github.wasiqb.coteafs.selenium.core.BrowserTest; import com.github.wasiqb.coteafs.selenium.pages.MainPage; import com.github.wasiqb.coteafs.selenium.pages.action.DeleteAccountPageAction; @@ -31,94 +28,95 @@ import com.github.wasiqb.coteafs.selenium.pages.action.NewAccountPageAction; import com.github.wasiqb.coteafs.selenium.pages.action.NewCustomerPageAction; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + /** * @author Wasiq Bhamla * @since Aug 15, 2018 8:07:59 PM */ public class SeleniumTest extends BrowserTest { - private String accountId; - private String customerId; - - /** - * @author Wasiq Bhamla - * @since Aug 19, 2018 4:30:34 PM - */ - @BeforeClass - public void setupMethod () { - final MainPage main = new MainPage (); - main.onDriver () - .navigateTo (appSetting ().getUrl ()); - } - - /** - * @author wasiqb - * @since Apr 8, 2019 10:34:29 PM - */ - @Test - public void testDeleteAccount () { - final DeleteAccountPageAction acc = new DeleteAccountPageAction (); - acc.addInputValue ("AccountId", this.accountId) - .perform (); - } + private String accountId; + private String customerId; - /** - * @author Wasiq Bhamla - * @since 29-Apr-2019 - */ - @Test - public void testDeleteCustomer () { - final DeleteCustomerPageAction acc = new DeleteCustomerPageAction (); - acc.addInputValue ("CustomerId", this.customerId) - .perform (); - } + /** + * @author Wasiq Bhamla + * @since Aug 19, 2018 4:30:34 PM + */ + @BeforeClass + public void setupMethod () { + final MainPage main = new MainPage (); + main.onDriver () + .navigateTo (appSetting ().getUrl ()); + } - /** - * @author wasiqb - * @since Apr 8, 2019 12:00:15 PM - */ - @Test - public void testEditCustomer () { - final EditCustomerPageAction cust = new EditCustomerPageAction (); - cust.addInputValue ("CustomerId", this.customerId) - .perform (); - } + /** + * @author wasiqb + * @since Apr 8, 2019 10:34:29 PM + */ + @Test + public void testDeleteAccount () { + final DeleteAccountPageAction acc = new DeleteAccountPageAction (); + acc.addInputValue ("AccountId", this.accountId) + .perform (); + } - /** - * @author wasiqb - * @since Apr 8, 2019 10:06:01 PM - */ - @Test - public void testNewAccount () { - final NewAccountPageAction acc = new NewAccountPageAction (); - acc.addInputValue ("CustomerId", this.customerId) - .perform (); + /** + * @author Wasiq Bhamla + * @since 29-Apr-2019 + */ + @Test + public void testDeleteCustomer () { + final DeleteCustomerPageAction acc = new DeleteCustomerPageAction (); + acc.addInputValue ("CustomerId", this.customerId) + .perform (); + } - this.accountId = acc.accountId (); - } + /** + * @author wasiqb + * @since Apr 8, 2019 12:00:15 PM + */ + @Test + public void testEditCustomer () { + final EditCustomerPageAction cust = new EditCustomerPageAction (); + cust.addInputValue ("CustomerId", this.customerId) + .perform (); + } - /** - * @author wasiqb - * @since Apr 8, 2019 10:52:16 AM - */ - @Test - public void testNewCustomer () { - final NewCustomerPageAction cust = new NewCustomerPageAction (); - cust.perform (); + /** + * @author wasiqb + * @since Apr 8, 2019 10:06:01 PM + */ + @Test + public void testNewAccount () { + final NewAccountPageAction acc = new NewAccountPageAction (); + acc.addInputValue ("CustomerId", this.customerId) + .perform (); + this.accountId = acc.accountId (); + } - this.customerId = cust.customerId (); - } + /** + * @author wasiqb + * @since Apr 8, 2019 10:52:16 AM + */ + @Test + public void testNewCustomer () { + final NewCustomerPageAction customerPageAction = new NewCustomerPageAction (); + customerPageAction.perform (); + this.customerId = customerPageAction.customerId (); + } - /** - * @author wasiqb - * @since Aug 31, 2018 9:15:42 PM - */ - @Test - public void testSignIn () { - final LoginPageAction login = new LoginPageAction (); - login.addInputValue (USER_ID, appSetting ().getParams () - .get ("user")) - .addInputValue (PASS, appSetting ().getParams () - .get ("password")) - .perform (); - } + /** + * @author wasiqb + * @since Aug 31, 2018 9:15:42 PM + */ + @Test + public void testSignIn () { + final LoginPageAction login = new LoginPageAction (); + login.addInputValue (USER_ID, appSetting ().getParams () + .get ("user")) + .addInputValue (PASS, appSetting ().getParams () + .get ("password")) + .perform (); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditAccountPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditAccountPage.java index deb1eed..fdb6308 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditAccountPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditAccountPage.java @@ -15,31 +15,31 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 8, 2019 10:17:16 PM */ public class EditAccountPage extends MainPage { - /** - * @author wasiqb - * @since Apr 8, 2019 10:20:19 PM - * @return account id - */ - public ITextboxActions accountId () { - return onTextbox (By.name ("accountno")); - } + /** + * @author wasiqb + * @since Apr 8, 2019 10:20:19 PM + * @return account id + */ + public ITextboxActions accountId () { + return onTextbox (By.name ("accountno"), "Account ID"); + } - /** - * @author wasiqb - * @since Apr 8, 2019 10:21:29 PM - * @return submit - */ - public IMouseActions submit () { - return onClickable (By.name ("AccSubmit")); - } + /** + * @author wasiqb + * @since Apr 8, 2019 10:21:29 PM + * @return submit + */ + public IMouseActions submit () { + return onClickable (By.name ("AccSubmit"), "Submit"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditCustomerPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditCustomerPage.java index 0cf6427..4cad845 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditCustomerPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/EditCustomerPage.java @@ -15,31 +15,31 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 8, 2019 11:44:28 AM */ public class EditCustomerPage extends MainPage { - /** - * @author wasiqb - * @since Apr 8, 2019 11:45:14 AM - * @return customer id - */ - public ITextboxActions customerId () { - return onTextbox (By.name ("cusid")); - } + /** + * @author wasiqb + * @since Apr 8, 2019 11:45:14 AM + * @return customer id + */ + public ITextboxActions customerId () { + return onTextbox (By.name ("cusid"), "Customer ID"); + } - /** - * @author wasiqb - * @since Apr 8, 2019 11:46:15 AM - * @return submit - */ - public IMouseActions submit () { - return onClickable (By.name ("AccSubmit")); - } + /** + * @author wasiqb + * @since Apr 8, 2019 11:46:15 AM + * @return submit + */ + public IMouseActions submit () { + return onClickable (By.name ("AccSubmit"), "Submit"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/LoginPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/LoginPage.java index 02d6026..edb5f14 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/LoginPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/LoginPage.java @@ -15,45 +15,45 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.BrowserPage; import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Aug 31, 2018 9:33:22 PM */ public class LoginPage extends BrowserPage { - /** - * @author wasiqb - * @since Aug 31, 2018 9:40:05 PM - * @return password - */ - public ITextboxActions password () { - return form ().find (By.name ("password")); - } + /** + * @author wasiqb + * @since Aug 31, 2018 9:40:05 PM + * @return password + */ + public ITextboxActions password () { + return form ().find (By.name ("password"), "Password"); + } - /** - * @author wasiqb - * @since Aug 31, 2018 9:40:56 PM - * @return signIn button - */ - public IMouseActions signIn () { - return form ().find (By.name ("btnLogin")); - } + /** + * @author wasiqb + * @since Aug 31, 2018 9:40:56 PM + * @return signIn button + */ + public IMouseActions signIn () { + return form ().find (By.name ("btnLogin"), "Login"); + } - /** - * @author wasiqb - * @since Aug 31, 2018 9:34:38 PM - * @return user id - */ - public ITextboxActions userId () { - return form ().find (By.name ("uid")); - } + /** + * @author wasiqb + * @since Aug 31, 2018 9:34:38 PM + * @return user id + */ + public ITextboxActions userId () { + return form ().find (By.name ("uid"), "User ID"); + } - private IMouseActions form () { - return onClickable (By.name ("frmLogin")); - } + private IMouseActions form () { + return onClickable (By.name ("frmLogin"), "Form"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/MainPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/MainPage.java index 24f8d75..8f68e8e 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/MainPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/MainPage.java @@ -15,41 +15,40 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.BrowserPage; import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Aug 31, 2018 8:14:38 PM */ public class MainPage extends BrowserPage { - /** - * @return manager welcome banner - * @since Apr 7, 2019 5:39:39 PM - */ - public IMouseActions managerIdBanner () { - return onClickable (By.cssSelector ("tr.heading3 > td")); - } + /** + * @return manager welcome banner + * @since Apr 7, 2019 5:39:39 PM + */ + public IMouseActions managerIdBanner () { + return onClickable (By.cssSelector ("tr.heading3 > td"), "Manager ID Banner"); + } - /** - * @param name - * name - * @return menu name - * @since Apr 7, 2019 5:42:12 PM - */ - public IMouseActions navbar (final String name) { - return navbar ().finds (By.cssSelector ("li > a")) - .stream () - .filter (m -> m.text () - .trim () - .equals (name)) - .findFirst () - .get (); - } + /** + * @param name name + * @return menu name + * @since Apr 7, 2019 5:42:12 PM + */ + public IMouseActions navbar (final String name) { + return navbar ().finds (By.cssSelector ("li > a"), name) + .stream () + .filter (m -> m.text () + .trim () + .equals (name)) + .findFirst () + .get (); + } - private IMouseActions navbar () { - return onClickable (By.className ("menusubnav")); - } + private IMouseActions navbar () { + return onClickable (By.className ("menusubnav"), "Navbar"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewAccountPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewAccountPage.java index 485eb5c..96cc9cd 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewAccountPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewAccountPage.java @@ -15,37 +15,37 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - 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 org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 8, 2019 12:03:03 PM */ public class NewAccountPage extends EditCustomerPage { - /** - * @author wasiqb - * @since Apr 8, 2019 12:05:04 PM - * @return account type - */ - public ISelectboxActions accountType () { - return onDropdown (By.name ("selaccount")); - } + /** + * @author wasiqb + * @since Apr 8, 2019 12:05:04 PM + * @return account type + */ + public ISelectboxActions accountType () { + return onDropdown (By.name ("selaccount"), "Account Type"); + } - /** - * @author wasiqb - * @since Apr 8, 2019 12:06:07 PM - * @return initial amount - */ - public ITextboxActions initialDeposit () { - return onTextbox (By.name ("inideposit")); - } + /** + * @author wasiqb + * @since Apr 8, 2019 12:06:07 PM + * @return initial amount + */ + public ITextboxActions initialDeposit () { + return onTextbox (By.name ("inideposit"), "Initial Deposit"); + } - @Override - public IMouseActions submit () { - return onClickable (By.name ("button2")); - } + @Override + public IMouseActions submit () { + return onClickable (By.name ("button2"), "Submit"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewCustomerPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewCustomerPage.java index ba13244..e6b4ee8 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewCustomerPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/NewCustomerPage.java @@ -17,124 +17,125 @@ import static java.lang.String.format; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 7, 2019 5:48:17 PM */ public class NewCustomerPage extends MainPage { - /** - * @author wasiqb - * @since Apr 7, 2019 5:59:04 PM - * @return address - */ - public ITextboxActions address () { - return onTextbox (By.name ("addr")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 5:59:04 PM + * @return address + */ + public ITextboxActions address () { + return onTextbox (By.name ("addr"), "Address"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 6:00:33 PM - * @return city - */ - public ITextboxActions city () { - return onTextbox (By.name ("city")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 6:00:33 PM + * @return city + */ + public ITextboxActions city () { + return onTextbox (By.name ("city"), "City"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 5:50:30 PM - * @return name - */ - public ITextboxActions customerName () { - return onTextbox (By.name ("name")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 5:50:30 PM + * @return name + */ + public ITextboxActions customerName () { + return onTextbox (By.name ("name"), "Customer Name"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 5:58:17 PM - * @return dob - */ - public ITextboxActions dob () { - return onTextbox (By.name ("dob")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 5:58:17 PM + * @return dob + */ + public ITextboxActions dob () { + return onTextbox (By.name ("dob"), "DOB"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 10:23:52 PM - * @return email - */ - public ITextboxActions email () { - return onTextbox (By.name ("emailid")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 10:23:52 PM + * @return email + */ + public ITextboxActions email () { + return onTextbox (By.name ("emailid"), "Email"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 5:52:55 PM - * @param gender - * Gender - * @return gender - */ - public IMouseActions gender (final char gender) { - if (gender != 'm' && gender != 'f') return gender ('m'); - return onClickable (By.cssSelector (format ("input[name='rad1'][value='%s']", gender))); - } + /** + * @author wasiqb + * @since Apr 7, 2019 5:52:55 PM + * @param gender Gender + * @return gender + */ + public IMouseActions gender (final char gender) { + if (gender != 'm' && gender != 'f') { + return gender ('m'); + } + return onClickable (By.cssSelector (format ("input[name='rad1'][value='%s']", gender)), "Gender"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 5:50:00 PM - * @return header - */ - public IMouseActions header () { - return onClickable (By.className ("heading3")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 5:50:00 PM + * @return header + */ + public IMouseActions header () { + return onClickable (By.className ("heading3"), "Header"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 10:23:08 PM - * @return mobile no - */ - public ITextboxActions mobileNumber () { - return onTextbox (By.name ("telephoneno")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 10:23:08 PM + * @return mobile no + */ + public ITextboxActions mobileNumber () { + return onTextbox (By.name ("telephoneno"), "Mobile Number"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 10:26:57 PM - * @return password - */ - public ITextboxActions password () { - return onTextbox (By.name ("password")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 10:26:57 PM + * @return password + */ + public ITextboxActions password () { + return onTextbox (By.name ("password"), "Password"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 6:04:02 PM - * @return pin - */ - public ITextboxActions pin () { - return onTextbox (By.name ("pinno")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 6:04:02 PM + * @return pin + */ + public ITextboxActions pin () { + return onTextbox (By.name ("pinno"), "Pin No"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 6:02:57 PM - * @return state - */ - public ITextboxActions state () { - return onTextbox (By.name ("state")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 6:02:57 PM + * @return state + */ + public ITextboxActions state () { + return onTextbox (By.name ("state"), "State"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 10:27:48 PM - * @return submit - */ - public IMouseActions submit () { - return onClickable (By.name ("sub")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 10:27:48 PM + * @return submit + */ + public IMouseActions submit () { + return onClickable (By.name ("sub"), "Submit"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessAccountPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessAccountPage.java index 41c7031..f613b3d 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessAccountPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessAccountPage.java @@ -15,35 +15,35 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 8, 2019 8:21:28 PM */ public class SuccessAccountPage extends SuccessPage { - /** - * @author wasiqb - * @since Apr 8, 2019 8:31:20 PM - * @return account id - */ - public IMouseActions accountId () { - return cell (3); - } + /** + * @author wasiqb + * @since Apr 8, 2019 8:31:20 PM + * @return account id + */ + public IMouseActions accountId () { + return cell (3); + } - /** - * @author wasiqb - * @since Apr 8, 2019 8:34:58 PM - * @return customer id - */ - public IMouseActions customerId () { - return cell (4); - } + /** + * @author wasiqb + * @since Apr 8, 2019 8:34:58 PM + * @return customer id + */ + public IMouseActions customerId () { + return cell (4); + } - @Override - protected IMouseActions successTable () { - return onClickable (By.id ("account")); - } + @Override + protected IMouseActions successTable () { + return onClickable (By.id ("account"), "Success Table"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessCustomerPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessCustomerPage.java index 2855a49..43abc1f 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessCustomerPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessCustomerPage.java @@ -15,35 +15,35 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 7, 2019 10:46:56 PM */ public class SuccessCustomerPage extends SuccessPage { - /** - * @author wasiqb - * @since Apr 7, 2019 10:38:33 PM - * @return customer id - */ - public IMouseActions customerId () { - return successTable ().find (By.cssSelector ("tbody > tr:nth-child(4) > td:last-child")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 10:38:33 PM + * @return customer id + */ + public IMouseActions customerId () { + return successTable ().find (By.cssSelector ("tbody > tr:nth-child(4) > td:last-child"), "Customer ID"); + } - /** - * @author wasiqb - * @since Apr 7, 2019 10:47:54 PM - * @return customer name - */ - public IMouseActions customerName () { - return successTable ().find (By.cssSelector ("tbody > tr:nth-child(5) > td:last-child")); - } + /** + * @author wasiqb + * @since Apr 7, 2019 10:47:54 PM + * @return customer name + */ + public IMouseActions customerName () { + return successTable ().find (By.cssSelector ("tbody > tr:nth-child(5) > td:last-child"), "Customer Name"); + } - @Override - protected IMouseActions successTable () { - return onClickable (By.id ("customer")); - } + @Override + protected IMouseActions successTable () { + return onClickable (By.id ("customer"), "Customer Table"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessPage.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessPage.java index 90c59e7..14e73df 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessPage.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/SuccessPage.java @@ -15,34 +15,34 @@ */ package com.github.wasiqb.coteafs.selenium.pages; -import org.openqa.selenium.By; - import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions; +import org.openqa.selenium.By; + /** * @author wasiqb * @since Apr 8, 2019 8:14:38 PM */ public abstract class SuccessPage extends MainPage { - /** - * @author wasiqb - * @since Apr 8, 2019 9:43:54 PM - * @return message - */ - public IMouseActions message () { - return cell (0, 0); - } + /** + * @author wasiqb + * @since Apr 8, 2019 9:43:54 PM + * @return message + */ + public IMouseActions message () { + return cell (0, 0); + } - protected abstract IMouseActions successTable (); + protected abstract IMouseActions successTable (); - IMouseActions cell (final int row) { - return cell (row, 1); - } + IMouseActions cell (final int row) { + return cell (row, 1); + } - private IMouseActions cell (final int row, final int col) { - return successTable ().finds (By.tagName ("tr")) - .get (row) - .finds (By.tagName ("td")) - .get (col); - } + private IMouseActions cell (final int row, final int col) { + return successTable ().finds (By.tagName ("tr"), "Row") + .get (row) + .finds (By.tagName ("td"), "Col") + .get (col); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteAccountPageAction.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteAccountPageAction.java index aaf2513..a6ff805 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteAccountPageAction.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteAccountPageAction.java @@ -23,24 +23,24 @@ * @author wasiqb * @since Apr 8, 2019 10:26:00 PM */ -public class DeleteAccountPageAction extends AbstractPageAction { - @Override - public void perform () { - final EditAccountPage acc = new EditAccountPage (); - acc.navbar ("Delete Account") - .click (); +public class DeleteAccountPageAction extends AbstractPageAction { + @Override + public void perform () { + final EditAccountPage acc = new EditAccountPage (); + acc.navbar ("Delete Account") + .click (); - acc.accountId () - .enterText (value ("AccountId")); - acc.submit () - .click (); + acc.accountId () + .enterText (value ("AccountId")); + acc.submit () + .click (); - acc.onDriver () - .verifyAlertMessage (AlertDecision.ACCEPT) - .isEqualTo ("Do you really want to delete this Account?"); + acc.onDriver () + .verifyAlertMessage (AlertDecision.ACCEPT) + .isEqualTo ("Do you really want to delete this Account?"); - acc.onDriver () - .verifyAlertMessage (AlertDecision.ACCEPT) - .isEqualTo ("Account Deleted Sucessfully"); - } + acc.onDriver () + .verifyAlertMessage (AlertDecision.ACCEPT) + .isEqualTo ("Account Deleted Sucessfully"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteCustomerPageAction.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteCustomerPageAction.java index db84c56..fd5fdb4 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteCustomerPageAction.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/DeleteCustomerPageAction.java @@ -23,24 +23,24 @@ * @author Wasiq Bhamla * @since 29-Apr-2019 */ -public class DeleteCustomerPageAction extends AbstractPageAction { - @Override - public void perform () { - final EditCustomerPage edit = new EditCustomerPage (); - edit.navbar ("Delete Customer") - .click (); +public class DeleteCustomerPageAction extends AbstractPageAction { + @Override + public void perform () { + final EditCustomerPage edit = new EditCustomerPage (); + edit.navbar ("Delete Customer") + .click (); - edit.customerId () - .enterText (value ("CustomerId").toString ()); - edit.submit () - .click (); + edit.customerId () + .enterText (value ("CustomerId").toString ()); + edit.submit () + .click (); - edit.onDriver () - .verifyAlertMessage (AlertDecision.ACCEPT) - .isEqualTo ("Do you really want to delete this Customer?"); + edit.onDriver () + .verifyAlertMessage (AlertDecision.ACCEPT) + .isEqualTo ("Do you really want to delete this Customer?"); - edit.onDriver () - .verifyAlertMessage (AlertDecision.ACCEPT) - .isEqualTo ("Customer deleted Successfully"); - } + edit.onDriver () + .verifyAlertMessage (AlertDecision.ACCEPT) + .isEqualTo ("Customer deleted Successfully"); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/EditCustomerPageAction.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/EditCustomerPageAction.java index e94297a..c80a86e 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/EditCustomerPageAction.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/EditCustomerPageAction.java @@ -25,59 +25,59 @@ * @author wasiqb * @since Apr 8, 2019 11:49:16 AM */ -public class EditCustomerPageAction extends AbstractPageAction { - @Override - public void perform () { - final EditCustomerPage edit = new EditCustomerPage (); - edit.navbar ("Edit Customer") - .click (); +public class EditCustomerPageAction extends AbstractPageAction { + @Override + public void perform () { + final EditCustomerPage edit = new EditCustomerPage (); + edit.navbar ("Edit Customer") + .click (); - edit.customerId () - .enterText (value ("CustomerId")); - edit.submit () - .click (); + edit.customerId () + .enterText (value ("CustomerId")); + edit.submit () + .click (); - final NewCustomerPage cust = new NewCustomerPage (); - final Faker fake = Faker.instance (); - cust.address () - .clear (); - cust.address () - .enterText (fake.address () - .streetAddress ()); - cust.city () - .clear (); - cust.city () - .enterText (fake.address () - .city ()); - cust.state () - .clear (); - cust.state () - .enterText (fake.address () - .state ()); - cust.pin () - .clear (); - cust.pin () - .enterText (fake.number () - .digits (6)); - cust.mobileNumber () - .clear (); - cust.mobileNumber () - .enterText (fake.number () - .digits (10)); - cust.email () - .clear (); - cust.email () - .enterText (fake.internet () - .emailAddress ()); - cust.submit () - .click (); + final NewCustomerPage cust = edit.nextPage (NewCustomerPage.class); + final Faker fake = Faker.instance (); + cust.address () + .clear (); + cust.address () + .enterText (fake.address () + .streetAddress ()); + cust.city () + .clear (); + cust.city () + .enterText (fake.address () + .city ()); + cust.state () + .clear (); + cust.state () + .enterText (fake.address () + .state ()); + cust.pin () + .clear (); + cust.pin () + .enterText (fake.number () + .digits (6)); + cust.mobileNumber () + .clear (); + cust.mobileNumber () + .enterText (fake.number () + .digits (10)); + cust.email () + .clear (); + cust.email () + .enterText (fake.internet () + .emailAddress ()); + cust.submit () + .click (); - final SuccessCustomerPage success = new SuccessCustomerPage (); - success.message () - .verifyText () - .isEqualTo ("Customer details updated Successfully!!!"); - success.customerId () - .verifyText () - .isEqualTo (value ("CustomerId")); - } + final SuccessCustomerPage success = new SuccessCustomerPage (); + success.message () + .verifyText () + .isEqualTo ("Customer details updated Successfully!!!"); + success.customerId () + .verifyText () + .isEqualTo (value ("CustomerId")); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/LoginPageAction.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/LoginPageAction.java index cc619c1..7223fa6 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/LoginPageAction.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/LoginPageAction.java @@ -25,29 +25,29 @@ * @author wasiqb * @since Sep 1, 2018 8:09:35 PM */ -public class LoginPageAction extends AbstractPageAction { - /** - * Password key. - */ - public static final String PASS = "password"; - /** - * User Id key. - */ - public static final String USER_ID = "userId"; +public class LoginPageAction extends AbstractPageAction { + /** + * Password key. + */ + public static final String PASS = "password"; + /** + * User Id key. + */ + public static final String USER_ID = "userId"; - @Override - public void perform () { - final LoginPage login = new LoginPage (); - login.userId () - .enterText (value (USER_ID)); - login.password () - .enterText (value (PASS)); - login.signIn () - .click (); + @Override + public void perform () { + final LoginPage login = new LoginPage (); + login.userId () + .enterText (value (USER_ID)); + login.password () + .enterText (value (PASS)); + login.signIn () + .click (); - final MainPage main = new MainPage (); - main.managerIdBanner () - .verifyText () - .endsWith (format ("Manger Id : {0}", value (USER_ID).toString ())); - } + login.nextPage (MainPage.class) + .managerIdBanner () + .verifyText () + .endsWith (format ("Manger Id : {0}", value (USER_ID).toString ())); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewAccountPageAction.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewAccountPageAction.java index e765944..b146409 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewAccountPageAction.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewAccountPageAction.java @@ -24,44 +24,45 @@ * @author wasiqb * @since Apr 8, 2019 8:05:24 PM */ -public class NewAccountPageAction extends AbstractPageAction { - private String accountId; +public class NewAccountPageAction extends AbstractPageAction { + private String accountId; - /** - * @author wasiqb - * @since Apr 8, 2019 10:00:42 PM - * @return account id - */ - public String accountId () { - return this.accountId; - } + /** + * @author wasiqb + * @since Apr 8, 2019 10:00:42 PM + * @return account id + */ + public String accountId () { + return this.accountId; + } - @Override - public void perform () { - final Faker fake = Faker.instance (); - final NewAccountPage acc = new NewAccountPage (); - acc.navbar ("New Account") - .click (); + @Override + public void perform () { + final Faker fake = Faker.instance (); + final NewAccountPage acc = new NewAccountPage (); + acc.navbar ("New Account") + .click (); - acc.customerId () - .enterText (value ("CustomerId")); - acc.accountType () - .selectByText (fake.bool () - .bool () ? "Current" : "Savings"); - acc.initialDeposit () - .enterText (fake.number () - .numberBetween (500, 100000) + ""); - acc.submit () - .click (); + acc.customerId () + .enterText (value ("CustomerId")); + acc.accountType () + .selectByText (fake.bool () + .bool () ? "Current" : "Savings"); + acc.initialDeposit () + .enterText (fake.number () + .numberBetween (500, 100000) + ""); + acc.submit () + .click (); - final SuccessAccountPage success = new SuccessAccountPage (); - success.message () - .verifyText () - .isEqualTo ("Account Generated Successfully!!!"); - success.customerId () - .verifyText () - .isEqualTo (value ("CustomerId")); - this.accountId = success.accountId () - .text (); - } + final SuccessAccountPage success = acc.nextPage (SuccessAccountPage.class); + + success.message () + .verifyText () + .isEqualTo ("Account Generated Successfully!!!"); + success.customerId () + .verifyText () + .isEqualTo (value ("CustomerId")); + this.accountId = success.accountId () + .text (); + } } \ No newline at end of file diff --git a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewCustomerPageAction.java b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewCustomerPageAction.java index 67f258a..4d95a0c 100644 --- a/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewCustomerPageAction.java +++ b/src/test/java/com/github/wasiqb/coteafs/selenium/pages/action/NewCustomerPageAction.java @@ -15,6 +15,8 @@ */ package com.github.wasiqb.coteafs.selenium.pages.action; +import static java.util.Arrays.stream; + import java.text.SimpleDateFormat; import com.github.javafaker.Faker; @@ -26,72 +28,69 @@ * @author wasiqb * @since Apr 7, 2019 10:51:02 PM */ -public class NewCustomerPageAction extends AbstractPageAction { - private String id; +public class NewCustomerPageAction extends AbstractPageAction { + private String id; - /** - * @author wasiqb - * @since Apr 8, 2019 11:37:44 AM - * @return id - */ - public String customerId () { - return this.id; - } + /** + * @author wasiqb + * @since Apr 8, 2019 11:37:44 AM + * @return id + */ + public String customerId () { + return this.id; + } - @Override - public void perform () { - final Faker fake = Faker.instance (); - final NewCustomerPage cust = new NewCustomerPage (); - cust.navbar ("New Customer") - .click (); - final String name = fake.name () - .firstName (); - cust.customerName () - .enterText (name); - cust.gender (fake.demographic () - .sex () - .charAt (0)); - final SimpleDateFormat df = new SimpleDateFormat ("dd-MM-yyyy"); - final String [] dates = df.format (fake.date () - .birthday (15, 50)) - .split ("-"); - for (final String date : dates) { - cust.dob () - .enterText (date); - } + @Override + public void perform () { + final Faker fake = Faker.instance (); + final NewCustomerPage cust = new NewCustomerPage (); + cust.navbar ("New Customer") + .click (); + final String name = fake.name () + .firstName (); + cust.customerName () + .enterText (name); + cust.gender (fake.demographic () + .sex () + .charAt (0)); + final SimpleDateFormat df = new SimpleDateFormat ("dd-MM-yyyy"); + final String [] dates = df.format (fake.date () + .birthday (15, 50)) + .split ("-"); + stream (dates).forEach (cust.dob ()::enterText); - cust.address () - .enterText (fake.address () - .streetAddress ()); - cust.city () - .enterText (fake.address () - .city ()); - cust.state () - .enterText (fake.address () - .state ()); - cust.pin () - .enterText (fake.number () - .digits (6)); - cust.mobileNumber () - .enterText (fake.number () - .digits (10)); - cust.email () - .enterText (fake.internet () - .emailAddress ()); - cust.password () - .enterText (fake.code () - .imei ()); - cust.submit () - .click (); + cust.address () + .enterText (fake.address () + .streetAddress ()); + cust.city () + .enterText (fake.address () + .city ()); + cust.state () + .enterText (fake.address () + .state ()); + cust.pin () + .enterText (fake.number () + .digits (6)); + cust.mobileNumber () + .enterText (fake.number () + .digits (10)); + cust.email () + .enterText (fake.internet () + .emailAddress ()); + cust.password () + .enterText (fake.code () + .imei ()); + cust.submit () + .click (); - final SuccessCustomerPage success = new SuccessCustomerPage (); - success.message () - .verifyText () - .isEqualTo ("Customer Registered Successfully!!!"); - success.customerName () - .verifyText () - .isEqualTo (name); - this.id = success.customerId () - .text (); - } + final SuccessCustomerPage success = cust.nextPage (SuccessCustomerPage.class); + success.message () + .verifyText () + .isEqualTo ("Customer Registered Successfully!!!"); + success.customerName () + .verifyText () + .isEqualTo (name); + this.id = success.customerId () + .text (); + } } \ No newline at end of file diff --git a/src/test/resources/listener-config.yml b/src/test/resources/listener-config.yml new file mode 100644 index 0000000..eda3e5e --- /dev/null +++ b/src/test/resources/listener-config.yml @@ -0,0 +1,12 @@ +log: + configurations: true + data_provider: true + execution: true + suites: true + tests: true +recover: + enable: true + logging: true + max_retry: 1 + on_exceptions: + - java.io.FileNotFoundException \ No newline at end of file diff --git a/src/test/resources/logger-config.yml b/src/test/resources/logger-config.yml new file mode 100644 index 0000000..8a83b3e --- /dev/null +++ b/src/test/resources/logger-config.yml @@ -0,0 +1,17 @@ +status: WARN +log_dir: /logs +loggers: + - name: console-log + type: CONSOLE + message_pattern: "[%d{HH:mm:ss.SSS}] [%-5level] - %msg (%logger{1}:%L) %throwable{short.message}%n" + level: DEBUG + - name: test-log-appender + type: FILE + file_name: new-log-main + path_pattern: my-log-main-%d{yyyy-MM-dd}.log + message_pattern: "[%d{HH:mm:ss.SSS}] [%-5level] - %msg (%logger{1}:%L) %throwable{short.message}%n" + level: INFO + archive: + after_days: 1 + after_size: 5 + on_every_run: true \ No newline at end of file diff --git a/src/test/resources/selenium-bs-config.yaml b/src/test/resources/selenium-bs-config.yaml index b706a9d..37ee440 100644 --- a/src/test/resources/selenium-bs-config.yaml +++ b/src/test/resources/selenium-bs-config.yaml @@ -15,7 +15,7 @@ remote: name: Bstack-[Java] Sample Test params: user: mngr26593 - password: abc@123 + password: ishal!12 playback: screen_state: NORMAL highlight: true @@ -35,7 +35,8 @@ playback: script_load: 60 highlight: 500 screenshot: - path: ~/screenshots + path: ./screenshots prefix: SCR extension: jpeg - capture_on_error: false \ No newline at end of file + capture_on_error: false + capture_all: true \ No newline at end of file diff --git a/src/test/resources/selenium-config.yaml b/src/test/resources/selenium-config.yaml index bd85fe8..93c483d 100644 --- a/src/test/resources/selenium-config.yaml +++ b/src/test/resources/selenium-config.yaml @@ -9,7 +9,7 @@ headless_mode: true # exe_url: https://driver/download/url params: user: mngr26593 - password: abc@123 + password: ishal!12 playback: screen_state: NORMAL highlight: true @@ -29,7 +29,12 @@ playback: script_load: 60 highlight: 500 screenshot: - path: ~/screenshots + path: ./screenshots prefix: SCR extension: jpeg - capture_on_error: false \ No newline at end of file + capture_on_error: false + capture_all: true + recording: + enable: false + path: ./video + prefix: VID \ No newline at end of file diff --git a/src/test/resources/selenium-grid-config.yaml b/src/test/resources/selenium-grid-config.yaml index c329b7c..5b43dfc 100644 --- a/src/test/resources/selenium-grid-config.yaml +++ b/src/test/resources/selenium-grid-config.yaml @@ -7,17 +7,17 @@ remote: source: GRID capabilities: browserName: chrome - version: 75.0 - platform: Windows 10 + version: 77.0.3865.75 + platform: LINUX params: user: mngr26593 - password: abc@123 + password: ishal!12 playback: screen_state: NORMAL highlight: true -# screen_resolution: -# width: 1280 -# height: 768 + # screen_resolution: + # width: 1280 + # height: 768 delays: implicit: 60 explicit: 60 @@ -31,7 +31,8 @@ playback: script_load: 60 highlight: 500 screenshot: - path: ~/screenshots + path: ./screenshots prefix: SCR extension: jpeg - capture_on_error: false \ No newline at end of file + capture_on_error: false + capture_all: true \ No newline at end of file diff --git a/src/test/resources/selenium-sauce-config.yaml b/src/test/resources/selenium-sauce-config.yaml index b9e0efd..48d10e1 100644 --- a/src/test/resources/selenium-sauce-config.yaml +++ b/src/test/resources/selenium-sauce-config.yaml @@ -7,7 +7,7 @@ remote: protocol: HTTPS url: ondemand.saucelabs.com source: SAUCELABS -# port: 80 + # port: 80 capabilities: browserName: chrome browserVersion: 75.0 @@ -17,13 +17,13 @@ remote: name: Sauce-[Java] Sample Test params: user: mngr26593 - password: abc@123 + password: ishal!12 playback: screen_state: NORMAL highlight: true -# screen_resolution: -# width: 1280 -# height: 768 + # screen_resolution: + # width: 1280 + # height: 768 delays: implicit: 60 explicit: 60 @@ -37,7 +37,8 @@ playback: script_load: 60 highlight: 500 screenshot: - path: ~/screenshots + path: ./screenshots prefix: SCR extension: jpeg - capture_on_error: false \ No newline at end of file + capture_on_error: false + capture_all: true \ No newline at end of file diff --git a/testng-all-browsers.xml b/testng-all-browsers.xml index 8bfa723..874635b 100644 --- a/testng-all-browsers.xml +++ b/testng-all-browsers.xml @@ -1,6 +1,14 @@ + + + + + + + + diff --git a/testng.xml b/testng.xml index 18ebc41..d9cd243 100644 --- a/testng.xml +++ b/testng.xml @@ -16,45 +16,48 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file