From eef7236db6381ba2a7666972f78e55d83f0e405d Mon Sep 17 00:00:00 2001 From: A247ZG Date: Mon, 18 Mar 2024 14:22:08 +0100 Subject: [PATCH] update with last functionalities --- pom.xml | 34 +- webengine-boot-gherkin/pom.xml | 3 +- .../webengine/helper/WebdriverHelper.java | 2 +- webengine-boot-keyword-driven/pom.xml | 3 +- .../webengine/boot/BootProject.java | 18 +- webengine-cmd-line/pom.xml | 3 +- webengine-core/pom.xml | 10 +- .../core/AbstractTestSuiteExecutor.java | 4 + .../properties/WebengineConfiguration.java | 2 - webengine-drive-by-excel/pom.xml | 25 +- .../webengine/ApplicationNoCode.java | 7 - .../webengine/boot/BootProjectNoCode.java | 30 +- .../webengine/cmd/AbstractDriverCommand.java | 111 +++- .../webengine/cmd/AssertContentCommand.java | 25 +- .../cmd/AssertNotContentCommand.java | 25 +- .../cmd/AssertNotSelectedCommand.java | 19 +- .../webengine/cmd/AssertSelectedCommand.java | 31 +- .../webengine/cmd/CheckByValueCommand.java | 27 + .../webengine/cmd/ClickCommand.java | 25 +- .../cmd/ClickPseudoElementCommand.java | 28 + .../webengine/cmd/CommandFactory.java | 20 + .../automation/webengine/cmd/CommandName.java | 223 ++++---- .../webengine/cmd/DeleteCookieCommand.java | 18 + .../webengine/cmd/DoubleClickCommand.java | 21 + .../webengine/cmd/ExitFrameCommand.java | 2 +- .../webengine/cmd/FullScrenshotCommand.java | 16 + .../automation/webengine/cmd/IfCommand.java | 77 ++- .../automation/webengine/cmd/OpenCommand.java | 39 +- .../cmd/OpenInPrivateModeCommand.java | 5 +- .../webengine/cmd/OpenTabCommand.java | 49 ++ .../webengine/cmd/PopUpCommand.java | 2 +- .../webengine/cmd/RefreshCommand.java | 2 +- .../cmd/SaveDataAndApplyRegexCommand.java | 31 + .../webengine/cmd/SaveDataCommand.java | 19 +- .../webengine/cmd/ScrollToElementCommand.java | 21 + .../webengine/cmd/SendKeysCommand.java | 29 +- .../cmd/SendKeysWithClearCommand.java | 20 +- .../cmd/SendKeysWithoutAssertionCommand.java | 16 + .../webengine/cmd/SwitchFrameCommand.java | 2 +- .../webengine/cmd/SwitchToCommand.java | 84 +++ .../webengine/cmd/UploadFileCommand.java | 2 - .../webengine/constante/ConstantNoCode.java | 3 +- .../constante/PredefinedDateTagValue.java | 17 +- .../constante/PredefinedTagValue.java | 12 +- .../ITestCaseNoCodeExecutor.java | 2 +- .../ITestStepNoCodeExecutor.java | 2 +- .../ITestSuiteNoCodeExecutor.java | 2 +- .../executor/TestCaseNoCodeExecutor.java | 14 +- .../executor/TestStepNoCodeExecutor.java | 3 +- .../executor/TestSuiteNoCodeExecutor.java | 6 +- .../webengine/global/DriverContext.java | 32 ++ .../webengine/helper/CommandResultHelper.java | 8 +- .../webengine/helper/EvaluateValueHelper.java | 42 +- .../webengine/helper/RobotHelper.java | 50 ++ .../webengine/object/CommandDataNoCode.java | 5 +- .../webengine/object/CommandResult.java | 4 +- .../axa/automation/webengine/SampleTest.java | 2 +- webengine-js/pom.xml | 18 + .../resources/js/css-selector-generator.js | 24 + .../src/main/resources/js/global-function.js | 7 + .../resources/js/shadow-dom-query-selector.js | 0 webengine-report-jacoco-aggregate/pom.xml | 3 +- webengine-report/pom.xml | 3 +- .../report/helper/global/ReportHelper.java | 5 +- .../html-report/assets/css/badge.css | 40 +- .../html-report/assets/css/body-content.css | 8 +- .../html-report/assets/css/content-view.css | 4 +- .../html-report/assets/css/global.css | 83 ++- .../html-report/assets/css/header.css | 25 +- .../resources/html-report/assets/css/tab.css | 20 +- .../html-report/assets/css/table.css | 45 +- .../resources/html-report/assets/css/tree.css | 120 ++-- .../resources/html-report/assets/js/global.js | 11 +- .../xslt/header/header-template.xslt | 23 +- .../xslt/header/sub-header-template.xslt | 17 +- .../resources/html-report/xslt/index.xslt | 2 + .../xslt/panel-left/panel-left-template.xslt | 39 +- .../xslt/panel-left/status-template.xslt | 49 +- .../content-tab-information-template.xslt | 29 +- .../content-tab/content-tab-log-template.xslt | 8 + .../general/array-view-template.xslt | 6 +- .../panel-right/panel-right-template.xslt | 24 - .../src/main/resources/xsd/webengine/type.xsd | 10 +- webengine-runner/pom.xml | 3 +- webengine-test-gherkin/pom.xml | 24 +- .../feature/model/WebEngineFirstStepPage.java | 2 + .../model/WebEngineFourthStepPage.java | 2 - .../feature/model/WebEngineHomeTestPage.java | 1 - .../model/WebEngineSecondStepPage.java | 2 - .../feature/model/WebEngineThirdStepPage.java | 2 - .../resources/features/sample-form.feature | 1 + webengine-test-keyword-driven/pom.xml | 24 +- .../appmodels/WebEngineFirstStepPage.java | 1 - .../appmodels/WebEngineFourthStepPage.java | 2 - .../appmodels/WebEngineHomeTestPage.java | 1 - .../appmodels/WebEngineSecondStepPage.java | 2 - .../appmodels/WebEngineThirdStepPage.java | 2 - .../testsuite/WebengineTestSuite.java | 4 +- webengine-test-linear/pom.xml | 3 +- .../java/fr/axa/automation/SampleTest.java | 2 +- .../java/fr/axa/automation/model/Page.java | 1 - webengine-util/pom.xml | 3 +- .../automation/webengine/util/DateUtil.java | 19 +- .../webengine/util/ExcelReader.java | 19 +- .../automation/webengine/util/FileUtil.java | 35 +- .../automation/webengine/util/FormatDate.java | 5 +- .../automation/webengine/util/ListUtil.java | 14 +- .../automation/webengine/util/RegexUtil.java | 2 +- webengine-web/pom.xml | 3 +- ...ibuteValueConstant.java => InputType.java} | 2 +- .../webengine/core/AbstractWebElement.java | 78 ++- .../webengine/core/PseudoElement.java | 17 + .../webengine/core/TestSuiteWebExecutor.java | 3 +- .../webengine/core/WebElementDescription.java | 539 ++++++++++++++---- .../webengine/global/AssertContentResult.java | 16 + .../webengine/global/BrowserDetail.java | 4 +- .../webengine/global/ElementContent.java | 13 + .../global/ElementContentInputTypeRadio.java | 13 + .../global/ElementContentSelect.java | 15 + .../webengine/global/SettingsWeb.java | 2 +- .../webengine/util/BrowserFactory.java | 60 +- .../webengine/util/ChromeDriverUtil.java | 11 +- .../webengine/util/EdgeDriverUtil.java | 17 +- .../webengine/util/FirefoxDriverUtil.java | 1 + .../webengine/util/FunctionUtil.java | 8 +- .../core/WebElementDescriptionTest.java | 12 +- 126 files changed, 2021 insertions(+), 926 deletions(-) create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CheckByValueCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickPseudoElementCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DeleteCookieCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DoubleClickCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/FullScrenshotCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenTabCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataAndApplyRegexCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ScrollToElementCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithoutAssertionCommand.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchToCommand.java rename webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/{api => executor}/ITestCaseNoCodeExecutor.java (96%) rename webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/{api => executor}/ITestStepNoCodeExecutor.java (93%) rename webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/{api => executor}/ITestSuiteNoCodeExecutor.java (92%) create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/global/DriverContext.java create mode 100644 webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/RobotHelper.java create mode 100644 webengine-js/pom.xml create mode 100644 webengine-js/src/main/resources/js/css-selector-generator.js create mode 100644 webengine-js/src/main/resources/js/global-function.js rename webengine-drive-by-excel/src/main/resources/querySelector.js => webengine-js/src/main/resources/js/shadow-dom-query-selector.js (100%) rename webengine-web/src/main/java/fr/axa/automation/webengine/constante/{HtmlAttributeValueConstant.java => InputType.java} (90%) create mode 100644 webengine-web/src/main/java/fr/axa/automation/webengine/core/PseudoElement.java create mode 100644 webengine-web/src/main/java/fr/axa/automation/webengine/global/AssertContentResult.java create mode 100644 webengine-web/src/main/java/fr/axa/automation/webengine/global/ElementContent.java create mode 100644 webengine-web/src/main/java/fr/axa/automation/webengine/global/ElementContentInputTypeRadio.java create mode 100644 webengine-web/src/main/java/fr/axa/automation/webengine/global/ElementContentSelect.java diff --git a/pom.xml b/pom.xml index 7a2ce99b..4a245043 100644 --- a/pom.xml +++ b/pom.xml @@ -4,17 +4,15 @@ 4.0.0 fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 pom webengine-parent - - - github - GitHub Packages - https://maven.pkg.github.com/AxaFrance/webengine-java - - + + fr.axa.socle.axafr + axafr-corporate-parent + 2.0.3 + 1.8 @@ -69,22 +67,24 @@ 5.2.3 2.13.2 + 3.1.1 webengine-util + webengine-js webengine-report webengine-core webengine-web webengine-runner - webengine-boot-keyword-driven - webengine-test-keyword-driven webengine-boot-gherkin - webengine-test-gherkin - webengine-test-linear - webengine-report-jacoco-aggregate + webengine-boot-keyword-driven webengine-drive-by-excel webengine-cmd-line + webengine-report-jacoco-aggregate + webengine-test-linear + webengine-test-gherkin + webengine-test-keyword-driven @@ -461,6 +461,14 @@ + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + diff --git a/webengine-boot-gherkin/pom.xml b/webengine-boot-gherkin/pom.xml index c0148b2b..bc85dfa3 100644 --- a/webengine-boot-gherkin/pom.xml +++ b/webengine-boot-gherkin/pom.xml @@ -5,11 +5,10 @@ fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 webengine-boot-gherkin - 3.0.11 jar webengine-boot-gherkin diff --git a/webengine-boot-gherkin/src/main/java/fr/axa/automation/webengine/helper/WebdriverHelper.java b/webengine-boot-gherkin/src/main/java/fr/axa/automation/webengine/helper/WebdriverHelper.java index 031b97e2..05814676 100644 --- a/webengine-boot-gherkin/src/main/java/fr/axa/automation/webengine/helper/WebdriverHelper.java +++ b/webengine-boot-gherkin/src/main/java/fr/axa/automation/webengine/helper/WebdriverHelper.java @@ -39,7 +39,7 @@ private static Optional getConfig() throws Exception { } public static Optional getDefaultDriver() throws WebEngineException { - return BrowserFactory.getWebDriver(Platform.WINDOWS, Browser.CHROMIUM_EDGE); + return BrowserFactory.getWebDriver(Platform.WINDOWS, Browser.CHROMIUM_EDGE,true); } public static void quiDriver(WebDriver webDriver) throws WebEngineException { diff --git a/webengine-boot-keyword-driven/pom.xml b/webengine-boot-keyword-driven/pom.xml index 9a720f69..bc4c00ed 100644 --- a/webengine-boot-keyword-driven/pom.xml +++ b/webengine-boot-keyword-driven/pom.xml @@ -5,11 +5,10 @@ fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 webengine-boot-keyword-driven - 3.0.11 jar webengine-boot-keyword-driven diff --git a/webengine-boot-keyword-driven/src/main/java/fr/axa/automation/webengine/boot/BootProject.java b/webengine-boot-keyword-driven/src/main/java/fr/axa/automation/webengine/boot/BootProject.java index 0ec007b2..a8655c7e 100644 --- a/webengine-boot-keyword-driven/src/main/java/fr/axa/automation/webengine/boot/BootProject.java +++ b/webengine-boot-keyword-driven/src/main/java/fr/axa/automation/webengine/boot/BootProject.java @@ -61,29 +61,21 @@ public void runTestSuite(CommandLine commandLine) throws WebEngineException, IOE ITestSuite testSuite = TestSuiteHelper.getTestSuite(); AbstractGlobalApplicationContext globalApplicationContext = getGlobalApplicationContext(commandLine, testSuite); - loggerService.info("Start Phase initialize test suite "); testSuiteExecutor.initialize(globalApplicationContext); - loggerService.info("End Phase initialize "); - - loggerService.info("Start run test "); if (testSuite instanceof AbstractTestSuite) { ((AbstractTestSuite) testSuite).setGlobalApplicationContext(globalApplicationContext); } TestSuiteReport testSuiteReport = ((ITestSuiteWebExecutor)testSuiteExecutor).run(globalApplicationContext, testSuite); - loggerService.info("End run test "); - - loggerService.info("Start clean "); testSuiteExecutor.cleanUp(globalApplicationContext); - loggerService.info("End clean "); - - loggerService.info("Start report "); Map reportsPath = reportHelper.generateReports(testSuiteReport, testSuite.getClass().getSimpleName(), globalApplicationContext.getSettings().getOutputDir()); - loggerService.info("End report "); if(globalApplicationContext.getSettings().isShowReport()) { - loggerService.info("Open report "); reportHelper.openReport(reportsPath.get(ReportPathKey.HTML_REPORT_PATH_KEY) + File.separator + "index.html"); - loggerService.info("End open report "); + } + if(testSuiteReport!=null && testSuiteReport.getFailed()>0){ + String errorMsg = "Test suite failed. Total number of test case :" + testSuiteReport.getNumberOfTestcase() +". Number of failed test : "+testSuiteReport.getFailed(); + loggerService.error(errorMsg); + throw new WebEngineException(errorMsg); } } diff --git a/webengine-cmd-line/pom.xml b/webengine-cmd-line/pom.xml index c3f2e928..4f289a96 100644 --- a/webengine-cmd-line/pom.xml +++ b/webengine-cmd-line/pom.xml @@ -6,11 +6,10 @@ fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 webengine-cmd-line - 3.0.11 jar webengine-cmd-line diff --git a/webengine-core/pom.xml b/webengine-core/pom.xml index 9f0dd40e..b9380f36 100644 --- a/webengine-core/pom.xml +++ b/webengine-core/pom.xml @@ -5,11 +5,10 @@ fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 webengine-core - 3.0.11 jar webengine-core @@ -21,6 +20,13 @@ ${project.parent.version} + + fr.axa.automation.webengine + webengine-js + ${project.parent.version} + + + org.springframework.boot spring-boot-starter diff --git a/webengine-core/src/main/java/fr/axa/automation/webengine/core/AbstractTestSuiteExecutor.java b/webengine-core/src/main/java/fr/axa/automation/webengine/core/AbstractTestSuiteExecutor.java index f04d8e35..f9083224 100644 --- a/webengine-core/src/main/java/fr/axa/automation/webengine/core/AbstractTestSuiteExecutor.java +++ b/webengine-core/src/main/java/fr/axa/automation/webengine/core/AbstractTestSuiteExecutor.java @@ -23,7 +23,9 @@ protected AbstractTestSuiteExecutor(ITestCaseExecutor testCaseExecutor, ILocalTe } public Object initialize(AbstractGlobalApplicationContext globalApplicationContext) { + loggerService.info("Start Phase initialize test suite "); runLocalTesting(globalApplicationContext); + loggerService.info("End Phase initialize "); return null; } @@ -32,7 +34,9 @@ private void runLocalTesting(AbstractGlobalApplicationContext globalApplicationC } public void cleanUp(Object object) { + loggerService.info("Start clean "); stopLocalTesting(); + loggerService.info("End clean "); } private void stopLocalTesting() { diff --git a/webengine-core/src/main/java/fr/axa/automation/webengine/properties/WebengineConfiguration.java b/webengine-core/src/main/java/fr/axa/automation/webengine/properties/WebengineConfiguration.java index cdf84319..28e64c31 100644 --- a/webengine-core/src/main/java/fr/axa/automation/webengine/properties/WebengineConfiguration.java +++ b/webengine-core/src/main/java/fr/axa/automation/webengine/properties/WebengineConfiguration.java @@ -18,9 +18,7 @@ public class WebengineConfiguration { String name; String platformName = null; String browserName = null; - String browserVersion = null; List browserOptionList; String outputDir; AppiumConfiguration appiumConfiguration; } - diff --git a/webengine-drive-by-excel/pom.xml b/webengine-drive-by-excel/pom.xml index 7655cf09..30e782b1 100644 --- a/webengine-drive-by-excel/pom.xml +++ b/webengine-drive-by-excel/pom.xml @@ -5,11 +5,10 @@ fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 webengine-drive-by-excel - 3.0.11 jar webengine-drive-by-excel @@ -147,7 +146,7 @@ maven-dependency-plugin - unpack + unpack-report generate-resources unpack @@ -165,9 +164,27 @@ + + unpack-js + generate-resources + + unpack + + + + + fr.axa.automation.webengine + webengine-js + ${project.parent.version} + jar + js/** + ${basedir}/src/main/resources/ + + + + - diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/ApplicationNoCode.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/ApplicationNoCode.java index 3f84a8ac..6e0a81ff 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/ApplicationNoCode.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/ApplicationNoCode.java @@ -34,13 +34,6 @@ public static void main(String[] args) { public void run(String... args) throws Exception { loggerService.info("***************Start automation***************"); loggerService.info("Temporary directory : "+System.getProperty("java.io.tmpdir")); - // java -jar drive-by-excel.jar "-data:file.xls" - // java -jar drive-by-excel.jar -Dspring.profiles.active=properties-chrome "-data:file.xls" "-tc:firsttestcase[-dataColumName:jdd-rec-auto;jdd-rec-moto] ; testcase2[-dataColumName:jdd-rec-moto]" "-browser:Chrome" "-platform:Android" - // java -jar drive-by-excel.jar "-data:file.xls" "-tc:firsttestcase, testcase2[-dataColumName:jdd-rec-moto]" - // java -jar drive-by-excel.jar "-data:file.xls" "-tc:firsttestcase, testcase2[-indexColumn:5]" - // java -jar drive-by-excel.jar "-data:file.xls" "-tc:firsttestcase, testcase2[-letterColumn:F]" - // "-data:C:\\work\\projet-git\\ExcelToJavaObjectConverter\\Test-1.xlsx" "-tc:devis-auto" "-platform:Windows" "-browser:ChromiumEdge" - bootProject.runFromFramework(args); loggerService.info("***************End automation***************"); } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/boot/BootProjectNoCode.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/boot/BootProjectNoCode.java index d1252d09..67ba805e 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/boot/BootProjectNoCode.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/boot/BootProjectNoCode.java @@ -1,6 +1,5 @@ package fr.axa.automation.webengine.boot; -import fr.axa.automation.webengine.api.ITestSuiteNoCodeExecutor; import fr.axa.automation.webengine.argument.ArgumentOption; import fr.axa.automation.webengine.checking.chain.IChecking; import fr.axa.automation.webengine.checking.chain.impl.AbstractChecking; @@ -12,6 +11,7 @@ import fr.axa.automation.webengine.checking.runner.impl.CheckingRunner; import fr.axa.automation.webengine.core.ITestSuiteExecutor; import fr.axa.automation.webengine.exception.WebEngineException; +import fr.axa.automation.webengine.executor.ITestSuiteNoCodeExecutor; import fr.axa.automation.webengine.executor.TestSuiteNoCodeExecutor; import fr.axa.automation.webengine.generated.TestSuiteReport; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; @@ -66,43 +66,33 @@ protected List getArgumentOptionProjet() { @Override public void runFromFramework(String... args) throws Exception { loggerService.info("Arguments : "+ ArgumentParser.removeOptionFromArguments(args,ArgumentOption.KEEPASS_PASSWORD)); + TestSuiteReport testSuiteReport = null; try{ CommandLine commandLine = getCommandLine(getArgumentOptionFramework(), args); AbstractGlobalApplicationContext globalApplicationContext = getGlobalApplicationContext(commandLine); TestSuiteDataNoCode testSuiteData = getTestSuiteData(globalApplicationContext); checkInput(globalApplicationContext,testSuiteData); - loggerService.info("Start Phase initialize test suite "); testSuiteExecutor.initialize(globalApplicationContext); - loggerService.info("End Phase initialize "); - - loggerService.info("Start run test "); - - TestSuiteReport testSuiteReport = ((ITestSuiteNoCodeExecutor) testSuiteExecutor).run(globalApplicationContext, testSuiteData); - loggerService.info("End run test "); - - loggerService.info("Start clean "); + testSuiteReport = ((ITestSuiteNoCodeExecutor) testSuiteExecutor).run(globalApplicationContext, testSuiteData); testSuiteExecutor.cleanUp(globalApplicationContext); - loggerService.info("End clean "); - - loggerService.info("Start report "); - testSuiteReport.getTestResults().get(0).setLog("Arguments : "+ArgumentParser.removeOptionFromArguments(args,ArgumentOption.KEEPASS_PASSWORD)); Map reportsPath = reportHelper.generateReports(testSuiteReport, "", globalApplicationContext.getSettings().getOutputDir()); - loggerService.info("End report "); if(globalApplicationContext.getSettings().isShowReport()) { - loggerService.info("Open report "); reportHelper.openReport(reportsPath.get(ReportPathKey.HTML_REPORT_PATH_KEY) + File.separator + "index.html"); - loggerService.info("End open report "); } if (((SettingsNoCode)globalApplicationContext.getSettings()).isDeleteTempFile()){ - loggerService.info("Delete temp file "); ((TestSuiteNoCodeExecutor) testSuiteExecutor).deleteTempFile(((SettingsNoCode) globalApplicationContext.getSettings()).getDataTestFileName()); - loggerService.info("End delete temp file "); } }catch (Exception e){ - loggerService.info("Error during execution of the automate. You can see more details in the file log"); + loggerService.error("Error during execution of the automate. You can see more details in the file log",e); + ApplicationDesktop.openFile(LoggerAppender.getFileAppender()); + } + if(testSuiteReport!=null && testSuiteReport.getFailed()>0){ + String errorMsg = "Test suite failed. Total number of test case :" + testSuiteReport.getNumberOfTestcase() +". Number of failed test : "+testSuiteReport.getFailed(); + loggerService.error(errorMsg); ApplicationDesktop.openFile(LoggerAppender.getFileAppender()); + throw new Exception(errorMsg); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AbstractDriverCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AbstractDriverCommand.java index 72980eca..7c066445 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AbstractDriverCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AbstractDriverCommand.java @@ -1,22 +1,25 @@ package fr.axa.automation.webengine.cmd; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import fr.axa.automation.webengine.constante.ConstantNoCode; import fr.axa.automation.webengine.constante.TargetKey; import fr.axa.automation.webengine.core.WebElementDescription; import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.generated.ActionReport; +import fr.axa.automation.webengine.generated.ArrayOfVariable; import fr.axa.automation.webengine.generated.Result; import fr.axa.automation.webengine.generated.ScreenshotReport; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.DriverContext; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; import fr.axa.automation.webengine.helper.ActionReportHelper; import fr.axa.automation.webengine.helper.CommandDataHelper; import fr.axa.automation.webengine.helper.CommandResultHelper; import fr.axa.automation.webengine.helper.EvaluateValueHelper; import fr.axa.automation.webengine.helper.GlobalConfigPropertiesHelper; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.logger.ILoggerService; import fr.axa.automation.webengine.logger.LoggerServiceProvider; import fr.axa.automation.webengine.object.CommandDataNoCode; @@ -36,6 +39,12 @@ import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.awt.image.RenderedImage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.AbstractMap; import java.util.ArrayList; import java.util.Calendar; @@ -43,6 +52,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; @FieldDefaults(level = AccessLevel.PROTECTED) @Data @@ -50,31 +60,35 @@ public abstract class AbstractDriverCommand implements ICommand { WebElementDescription webElementDescription; List screenshotReportList = new ArrayList<>(); - WebDriver webDriver; + DriverContext driverContext; String savedData; ILoggerService loggerService = LoggerServiceProvider.getInstance(); - StringBuffer logReport = new StringBuffer(); + ArrayOfVariable logReport = new ArrayOfVariable(); public abstract void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception; public WebDriver initializeWebDriver(AbstractGlobalApplicationContext globalApplicationContext) throws WebEngineException { - return getDriver(globalApplicationContext,false); + return initializeWebDriver(globalApplicationContext, true); + } + + public WebDriver initializeWebDriver(AbstractGlobalApplicationContext globalApplicationContext, boolean deleteCookie) throws WebEngineException { + return getDriver(globalApplicationContext,false, deleteCookie); } public WebDriver initializeIncognitoWebDriver(AbstractGlobalApplicationContext globalApplicationContext) throws WebEngineException { - return getDriver(globalApplicationContext,true); + return getDriver(globalApplicationContext,true, true); } - public WebDriver getDriver(AbstractGlobalApplicationContext globalApplicationContext,boolean incognito) throws WebEngineException { + public WebDriver getDriver(AbstractGlobalApplicationContext globalApplicationContext,boolean incognito, boolean deleteCookie) throws WebEngineException { try { GlobalConfiguration globalConfiguration = GlobalConfigPropertiesHelper.getGlobalConfigProperties(globalApplicationContext.getSettings()); - Optional optional = null; + Optional optional ; if(incognito){ optional = BrowserFactory.getIncognitoDriver(globalConfiguration); }else { - optional = BrowserFactory.getDriver(globalConfiguration); + optional = BrowserFactory.getDriver(globalConfiguration,deleteCookie); } if(optional.isPresent()){ return optional.get(); @@ -87,7 +101,7 @@ public WebDriver getDriver(AbstractGlobalApplicationContext globalApplicationCon protected WebElementDescription populateWebElement(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws WebEngineException{ Map.Entry entry = getTargetValue(globalApplicationContext, commandData, commandResultList); - WebDriver webDriver = getWebDriverToUse(globalApplicationContext,testCaseContext,commandResultList); + WebDriver webDriver = getWebDriverToUse(commandResultList); if(entry==null){ return WebElementDescription.builder() .useDriver(webDriver) @@ -107,6 +121,7 @@ protected WebElementDescription populateWebElement(AbstractGlobalApplicationCont .build(); case COMBINAISON_OF_LOCATOR: ObjectMapper mapper = new ObjectMapper(); + mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); try { WebElementDescription webElementDescription = mapper.readValue(entry.getValue(), WebElementDescription.class); webElementDescription.setUseDriver(webDriver); @@ -148,54 +163,98 @@ protected Map.Entry getTargetValue(AbstractGlobalApplicationCo public CommandResult execute(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws WebEngineException { ActionReport actionReport = ActionReportHelper.getActionReport(commandData.getName()); - getLogReport().append("Executed command : ").append(commandData); + String dataTestColumName = ((TestCaseNoCodeContext) testCaseContext).getDataTestColumnName(); + loggerService.info("--------------------------------------------------------------------------------------------------------------------------------"); + loggerService.info("Executed command : " + commandData); + getLogReport().getVariables().add(VariableHelper.getVariable("Executed command", commandData.getCommand().name())); + Map.Entry targetEntry = getTargetValue(globalApplicationContext, commandData, commandResultList); + getLogReport().getVariables().add(VariableHelper.getVariable("Target", targetEntry == null ? "" : targetEntry.getValue())); + String evaluateValue = getValue(globalApplicationContext, (TestCaseNoCodeContext)testCaseContext, commandData, commandResultList); + getLogReport().getVariables().add(VariableHelper.getVariable("Data", evaluateValue == null ? "" : evaluateValue)); try { - String dataTestColumName = ((TestCaseNoCodeContext) testCaseContext).getDataTestColumnName(); if (CommandDataHelper.canExecuteDataTestColumn(commandData.getDataTestReferenceList(), dataTestColumName)) { executeCmd(globalApplicationContext, testCaseContext, commandData, commandResultList); actionReport.getScreenshots().getScreenshotReports().addAll(getScreenshotReportList()); actionReport.setResult(Result.PASSED); - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append("Status : ").append(Result.PASSED.value()); + getLogReport().getVariables().add(VariableHelper.getVariable("Status", Result.PASSED.value())); } else { actionReport.setResult(Result.IGNORED); - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append("Warning : ").append(ConstantNoCode.CR_LF.getValue()).append(" Command ignored because the colum data-test-ref not contains '" + dataTestColumName + "' column "); + getLogReport().getVariables().add(VariableHelper.getVariable("Warning", "Command ignored because the colum data-test-ref not contains '" + dataTestColumName + "' column ")); } - actionReport.setLog(getLogReport().toString()); + actionReport.setLogMap(getLogReport()); } catch (Throwable e) { - actionReport.getScreenshots().getScreenshotReports().add(screenShot(globalApplicationContext,testCaseContext,"",commandResultList)); + if(getWebDriverToUse(commandResultList)!=null){ + actionReport.getScreenshots().getScreenshotReports().add(screenShot(globalApplicationContext,testCaseContext,"",commandResultList)); + } if (commandData.isOptional() || commandData.getCommand() == CommandName.IF || commandData.getCommand() == CommandName.ELSE_IF) { actionReport.setName(actionReport.getName() + " - /!\\ Failed but ignored (Optional or If/else if/else)"); actionReport.setResult(Result.IGNORED); - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append("Warning : ").append(ConstantNoCode.CR_LF.getValue()).append(" Command failed but ignored because this command is optional "); + getLogReport().getVariables().add(VariableHelper.getVariable("Warning", "Command failed but ignored because this command is optional")); }else{ actionReport.setResult(Result.FAILED); - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append("Status : ").append(Result.FAILED.value()); + getLogReport().getVariables().add(VariableHelper.getVariable("Status", Result.FAILED.value())); } - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append("Exception : ").append(ConstantNoCode.CR_LF.getValue()).append(ExceptionUtils.getStackTrace(e)); - actionReport.setLog(getLogReport().toString()); + getLogReport().getVariables().add(VariableHelper.getVariable("Cause", e.getMessage())); + getLogReport().getVariables().add(VariableHelper.getVariable("Exception", ExceptionUtils.getStackTrace(e))); + actionReport.setLogMap(getLogReport()); } finally { actionReport.setEndTime(Calendar.getInstance()); } - loggerService.info(getLogReport().toString()); + + loggerService.info("Status command : "+actionReport.getResult()); return CommandResult.builder() .commandData(commandData) .actionReport(actionReport) - .webDriver(webDriver) + .driverContext(driverContext) .savedData(savedData).build(); } protected ScreenshotReport screenShot(AbstractGlobalApplicationContext globalApplicationContext,AbstractTestCaseContext testCaseContext,String name, List commandResultList) throws WebEngineException { - WebDriver webDriver = getWebDriverToUse(globalApplicationContext,testCaseContext,commandResultList); + WebDriver webDriver = getWebDriverToUse(commandResultList); byte[] screenshot = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.BYTES); return ScreenshotHelper.getScreenshotReport(name, screenshot); } - protected WebDriver getWebDriverToUse(AbstractGlobalApplicationContext globalApplicationContext,AbstractTestCaseContext testCaseContext, List commandResultList) throws WebEngineException { - List webDriverList = CommandResultHelper.getWebDriverList(commandResultList); + protected ScreenshotReport fullScreenShot(AbstractGlobalApplicationContext globalApplicationContext,AbstractTestCaseContext testCaseContext,String name, List commandResultList) throws WebEngineException { + try { + RenderedImage img = getGeneratedCurrentDesktopImage(); + byte[] screenshot = getImgByteArray(img); + return ScreenshotHelper.getScreenshotReport(name, screenshot); + } catch (Exception e) { + loggerService.warn("Error during full screenshot", e); + loggerService.info("Try to take a screenshot with the driver"); + return screenShot(globalApplicationContext,testCaseContext,name,commandResultList); + } + } + + private RenderedImage getGeneratedCurrentDesktopImage() { + Robot robot = null; + try { + robot = new Robot(); + BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); + return screenShot; + } catch (AWTException e) { + loggerService.warn("Error during get generated current desktop image", e); + } + + return new BufferedImage(Toolkit.getDefaultToolkit().getScreenSize().width,Toolkit.getDefaultToolkit().getScreenSize().height,Image.SCALE_DEFAULT); + } + + private byte[] getImgByteArray(RenderedImage img) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + ImageIO.write(img, "png", baos); + } catch (IOException e) { + loggerService.warn("Error during get image byte array", e); + } + return baos.toByteArray(); + } - if(CollectionUtils.isNotEmpty(webDriverList)){ - return ListUtil.getLastElement(webDriverList).get(); + protected WebDriver getWebDriverToUse(List commandResultList) throws WebEngineException { + List driverContextList = CommandResultHelper.getWebDriverList(commandResultList); + if(CollectionUtils.isNotEmpty(driverContextList)){ + return ListUtil.getLastElement(driverContextList.stream().collect(Collectors.toList())).get().getWebDriver(); } return null; } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertContentCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertContentCommand.java index 4a18c631..6803afb4 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertContentCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertContentCommand.java @@ -1,36 +1,27 @@ package fr.axa.automation.webengine.cmd; -import fr.axa.automation.webengine.constante.ConstantNoCode; import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.AssertContentResult; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; public class AssertContentCommand extends AbstractDriverCommand { @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); - String expected = getValue(globalApplicationContext, (TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - Map> contentMap = webElementDescription.getContentByElementType(expected); - - Map> filterContentMap = contentMap.entrySet().stream() - .filter(entry -> entry.getValue().contains(expected) || entry.getKey().contains(expected)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - if (MapUtils.isEmpty(filterContentMap)) { - String errorMessage = "The expected value is : '" + expected + "'"; - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append(errorMessage); - errorMessage = "The actual contentMap is : '" + StringUtils.substringBetween(contentMap.values().toString(), "[[", "]]") +"'"; - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append(errorMessage); + String expectedValue = getValue(globalApplicationContext, (TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + AssertContentResult assertContentResult = webElementDescription.assertContentByElementType(expectedValue); + if(!assertContentResult.isResult()){ + String errorMessage = "The expected value is : '" + expectedValue + "' and the actual value is : '" + assertContentResult.getActualValue() + "'"; + getLogReport().getVariables().add(VariableHelper.getVariable("Expected value", expectedValue)); + getLogReport().getVariables().add(VariableHelper.getVariable("Actual value", assertContentResult.getActualValue())); throw new WebEngineException(errorMessage); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotContentCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotContentCommand.java index 50eac493..0a8f1db3 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotContentCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotContentCommand.java @@ -1,33 +1,26 @@ package fr.axa.automation.webengine.cmd; -import fr.axa.automation.webengine.constante.ConstantNoCode; import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.AssertContentResult; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; -import org.apache.commons.collections4.MapUtils; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; public class AssertNotContentCommand extends AbstractDriverCommand{ - @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ - webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String expected = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - Map> contentMap = webElementDescription.getContentByElementType(expected); - - Map> filterContentMap = contentMap.entrySet().stream() - .filter(entry -> entry.getValue().contains(expected) || entry.getKey().contains(expected)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - if (MapUtils.isNotEmpty(filterContentMap)) { - String errorMessage = "The expected value is : " + expected + " and the actual contentMap is : " + contentMap; - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append(errorMessage); + webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); + String expectedValue = getValue(globalApplicationContext, (TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + AssertContentResult assertContentResult = webElementDescription.assertContentByElementType(expectedValue); + if(assertContentResult.isResult()){ + String errorMessage = "The expected value is : '" + expectedValue + "' and the actual value is : '" + assertContentResult.getActualValue() + "'"; + getLogReport().getVariables().add(VariableHelper.getVariable("Expected value", expectedValue)); + getLogReport().getVariables().add(VariableHelper.getVariable("Actual value", assertContentResult.getActualValue())); throw new WebEngineException(errorMessage); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotSelectedCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotSelectedCommand.java index 53eef746..e8d66ee2 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotSelectedCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertNotSelectedCommand.java @@ -1,27 +1,28 @@ package fr.axa.automation.webengine.cmd; -import fr.axa.automation.webengine.constante.ConstantNoCode; import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.ElementContentSelect; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; -import fr.axa.automation.webengine.util.StringUtil; import java.util.List; -public class AssertNotSelectedCommand extends AbstractDriverCommand{ +public class AssertNotSelectedCommand extends AssertSelectedCommand{ @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - String selectedOption = webElementDescription.getSelectedOption(); - if(StringUtil.equalsIgnoreCase(value,selectedOption)){ - String errorMessage = "The expected value is : "+value+" and the actual selected option is : "+selectedOption; - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append(errorMessage); - throw new WebEngineException(errorMessage); + String expectedValue = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + ElementContentSelect elementContentSelect = (ElementContentSelect)webElementDescription.getSelectedOption(); + if(assertion(elementContentSelect,expectedValue)){ + String errorMessage = "The expected value is : '" + expectedValue + "' The actual selected option is : '" + elementContentSelect.getValueAndTextMap().entrySet().stream().findFirst().get() + "'"; + getLogReport().getVariables().add(VariableHelper.getVariable("Expected value", expectedValue)); + getLogReport().getVariables().add(VariableHelper.getVariable("Actual value", String.valueOf(elementContentSelect.getValueAndTextMap().entrySet().stream().findFirst().get()))); + throw new WebEngineException(errorMessage); } } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertSelectedCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertSelectedCommand.java index 1b3003b8..65446771 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertSelectedCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/AssertSelectedCommand.java @@ -1,13 +1,15 @@ package fr.axa.automation.webengine.cmd; -import fr.axa.automation.webengine.constante.ConstantNoCode; import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.ElementContentSelect; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; import fr.axa.automation.webengine.util.StringUtil; +import org.apache.commons.collections4.MapUtils; import java.util.List; @@ -16,12 +18,27 @@ public class AssertSelectedCommand extends AbstractDriverCommand{ @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - String selectedOption = webElementDescription.getSelectedOption(); - if(!StringUtil.equalsIgnoreCase(value,selectedOption)){ - String errorMessage = "The value is : "+value+" and the selected option is : "+selectedOption; - getLogReport().append(ConstantNoCode.CR_LF.getValue()).append(errorMessage); - throw new WebEngineException(errorMessage); + String expectedValue = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + ElementContentSelect elementContentSelect = (ElementContentSelect)webElementDescription.getSelectedOption(); + if(!assertion(elementContentSelect,expectedValue)){ + String errorMessage = "The expected value is : '" + expectedValue + "' and the actual value is : '" + elementContentSelect.getValueAndTextMap().entrySet().stream().findFirst().get() + "'"; + getLogReport().getVariables().add(VariableHelper.getVariable("Expected value", expectedValue)); + getLogReport().getVariables().add(VariableHelper.getVariable("Actual value", String.valueOf(elementContentSelect.getValueAndTextMap().entrySet().stream().findFirst().get()))); + throw new WebEngineException(errorMessage); } } + + protected boolean assertion(ElementContentSelect elementContentSelect, String expected){ + if(elementContentSelect != null && MapUtils.isNotEmpty(elementContentSelect.getValueAndTextMap())){ + String actualValue = elementContentSelect.getValueAndTextMap().entrySet().stream().findFirst().get().getKey(); + if(StringUtil.equalsIgnoreCase(expected, actualValue)){ + return true; + } + String actualText = elementContentSelect.getValueAndTextMap().entrySet().stream().findFirst().get().getValue(); + if(actualText.contains(expected)){ + return true; + } + } + return false; + } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CheckByValueCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CheckByValueCommand.java new file mode 100644 index 00000000..477c314a --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CheckByValueCommand.java @@ -0,0 +1,27 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +public class CheckByValueCommand extends AbstractDriverCommand{ + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ + webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); + String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + executeActionInElement(StringUtils.trimToEmpty(value)); + } + + protected void executeActionInElement(String value)throws Exception { + if(StringUtils.isEmpty(value)){ + throw new Exception("The value is empty, we can't determine the checkbox or radio to click"); + } + webElementDescription.checkByValue(value); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickCommand.java index 450b48c6..b7999d50 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickCommand.java @@ -2,31 +2,24 @@ import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; -import fr.axa.automation.webengine.global.TestCaseNoCodeContext; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; -import org.apache.commons.lang3.StringUtils; import java.util.List; -public class ClickCommand extends AbstractDriverCommand{ +public class ClickCommand extends AbstractDriverCommand { @Override - public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ - webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - executeActionInElement(StringUtils.trimToEmpty(value)); + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { + webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); + executeActionInElement(); } - protected void executeActionInElement(String value)throws Exception { - if(StringUtils.isEmpty(value)){ - try { - webElementDescription.focusAndClick(); - }catch (Exception e) { - webElementDescription.focusAndClickWithJS(); - } - } else if (webElementDescription.isInputRadio()) { - webElementDescription.checkByValue(value); + protected void executeActionInElement() throws Exception { + try { + webElementDescription.focusAndClick(); + } catch (Exception e) { + webElementDescription.focusAndClickWithJS(); } } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickPseudoElementCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickPseudoElementCommand.java new file mode 100644 index 00000000..d51fdc17 --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ClickPseudoElementCommand.java @@ -0,0 +1,28 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.exception.WebEngineException; +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; + +import java.util.List; + +public class ClickPseudoElementCommand extends ClickCommand { + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { + webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); + executeActionInElement(); + } + + @Override + protected void executeActionInElement() throws Exception { + if(webElementDescription.getPseudoElement() != null){ + webElementDescription.focusAndClickOnPseudoElement(); + }else { + throw new WebEngineException("Pseudo element is null"); + } + + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandFactory.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandFactory.java index fd943d99..491fdcc8 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandFactory.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandFactory.java @@ -10,16 +10,32 @@ public static AbstractDriverCommand getCommand(CommandDataNoCode commandData) th return new OpenCommand(); case OPEN_PRIVATE: return new OpenInPrivateModeCommand(); + case SWITCH_TO: + return new SwitchToCommand(); + case OPEN_TAB: + return new OpenTabCommand(); + case DELETE_COOKIE: + return new DeleteCookieCommand(); case CLEAR: return new ClearCommand(); case SEND_KEYS: return new SendKeysCommand(); + case SEND_KEYS_WITHOUT_ASSERTION: + return new SendKeysWithoutAssertionCommand(); case SEND_KEYS_WITH_CLEAR: return new SendKeysWithClearCommand(); case CLICK: return new ClickCommand(); + case CLICK_ON_PSEUDO_ELEMENT: + return new ClickPseudoElementCommand(); + case DOUBLE_CLICK: + return new DoubleClickCommand(); case SAVE_DATA: return new SaveDataCommand(); + case SAVE_DATA_AND_APPLY_REGEX: + return new SaveDataAndApplyRegexCommand(); + case CHECK_BY_VALUE: + return new CheckByValueCommand(); case CALL: return new CallCommand(); case SELECT: @@ -38,6 +54,8 @@ public static AbstractDriverCommand getCommand(CommandDataNoCode commandData) th return new AssertNotCheckedCommand(); case SCREENSHOT: return new ScrenshotCommand(); + case FULLSCREENSHOT: + return new FullScrenshotCommand(); case ASSERT_CONTENT: return new AssertContentCommand(); case ASSERT_NOT_CONTENT: @@ -58,6 +76,8 @@ public static AbstractDriverCommand getCommand(CommandDataNoCode commandData) th return new SwitchFrameCommand(); case EXIT_FRAME: return new ExitFrameCommand(); + case SCROLL_TO_ELEMENT: + return new ScrollToElementCommand(); case REFRESH: return new RefreshCommand(); default: diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandName.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandName.java index 9701675c..7c0e3726 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandName.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/CommandName.java @@ -17,95 +17,122 @@ @AllArgsConstructor public enum CommandName { - OPEN(ImmutableMap.of( Locale.ENGLISH, "open" , Locale.FRENCH, "ouvrir" ), - ImmutableMap.of( Locale.ENGLISH, "Open browser with the given url" , - Locale.FRENCH, "Ouverture du navigateur avec l'url indiqué" )), - OPEN_PRIVATE(ImmutableMap.of( Locale.ENGLISH, "open private" , Locale.FRENCH, "ouvrir en mode privé" ), - ImmutableMap.of( Locale.ENGLISH, "Open browser in private mode with the given url" , - Locale.FRENCH, "Ouverture du navigateur en mode privé avec l'url indiqué" )), - CLEAR(ImmutableMap.of( Locale.ENGLISH, "Clear" ,Locale.FRENCH, "Effacer" ), - ImmutableMap.of( Locale.ENGLISH, "Clear the given text field" , - Locale.FRENCH, "Effacer le champ texte défini dans la colonne identification" )), - - SEND_KEYS(ImmutableMap.of( Locale.ENGLISH, "send keys" ,Locale.FRENCH, "écrire" ), - ImmutableMap.of( Locale.ENGLISH, "Send keys to the given text field" , - Locale.FRENCH, "Ecriture dans le champ texte défini dans la colonne identification" )), - - SEND_KEYS_WITH_CLEAR(ImmutableMap.of( Locale.ENGLISH, "send keys with clear" ,Locale.FRENCH, "écrire et effacer avant le champ" ), - ImmutableMap.of( Locale.ENGLISH, "Send keys to the given text field" , - Locale.FRENCH, "Ecriture dans le champ texte défini dans la colonne identification" )), - - CLICK(ImmutableMap.of( Locale.ENGLISH, "click" , Locale.FRENCH, "cliquer" ), - ImmutableMap.of( Locale.ENGLISH, "Click on the given element" , - Locale.FRENCH, "Clic sur l'élément indiqué" )), - SELECT(ImmutableMap.of( Locale.ENGLISH, "select" , Locale.FRENCH, "séléctionner" ), - ImmutableMap.of( Locale.ENGLISH, "Select the given value in the given drop down list" , Locale.FRENCH, - "Sélectionne la valeur indiquée dans la liste déroulante définie dans la colonne identification" )), - CALL(ImmutableMap.of( Locale.ENGLISH, "call" , Locale.FRENCH, "appeler" ), - ImmutableMap.of( Locale.FRENCH, "Execute le sous-scénario définie dans la colonne Identification" , - Locale.ENGLISH, "Execute the sub-scenario defined in the Identification column" )), - IF(ImmutableMap.of( Locale.ENGLISH, "if" , Locale.FRENCH, "si" ), - ImmutableMap.of( Locale.FRENCH, "Si la condition définie dans la colonne des valeurs <<>>,<<>>,etc; les lignes en dessous sont exécutées" , - Locale.ENGLISH, "If the condition defined in the values column <<>>,<<>>,etc; the lines below are executed" )), - ELSE_IF(ImmutableMap.of( Locale.ENGLISH, "else if" , Locale.FRENCH, "sinon si" ), - ImmutableMap.of( Locale.FRENCH, "Si la condition définie dans la colonne des valeurs <<>>,<<>>,etc; les lignes en dessous sont exécutées" , - Locale.ENGLISH, "If the condition defined in the values column <<>>,<<>>,etc; the lines below are executed" )), - ELSE(ImmutableMap.of( Locale.ENGLISH, "else" , Locale.FRENCH, "sinon" ), - ImmutableMap.of( Locale.FRENCH, "Si la condition définie dans le IF au dessus n'est pas respecté, les lignes en dessous sont exécutées" , - Locale.ENGLISH, "If the condition defined in the IF above is not respected, the lines below are executed" )), - END_IF(ImmutableMap.of( Locale.ENGLISH, "end if" , Locale.FRENCH, "fin si" ) - ,ImmutableMap.of( Locale.FRENCH, "Fin d'un bloc IF" , - Locale.ENGLISH, "End of an IF block" )), - SAVE_DATA(ImmutableMap.of( Locale.ENGLISH, "save data" ,Locale.FRENCH, "enregistrer" ), - ImmutableMap.of( Locale.FRENCH, "Enregistre la valeur définie ou le contenu de l'élément indiqu\" si la colonne valeur est vide" , - Locale.ENGLISH, "Save the defined value or the content of the element indicated if the value column is empty" )), - ASSERT_EXIST(ImmutableMap.of( Locale.ENGLISH, "assert exist" ,Locale.FRENCH, "existe ?" ), - ImmutableMap.of( Locale.FRENCH, "Vérifie que l'élement défini existe dans la page web" , - Locale.ENGLISH, "Check that the defined element exists in the web page" )), - ASSERT_NOT_EXIST(ImmutableMap.of( Locale.ENGLISH, "assert not exist" ,Locale.FRENCH, "n'existe pas ?" ), - ImmutableMap.of( Locale.FRENCH, "Vérifie la valeur indiqué est contenu dans l'élement défini" , - Locale.ENGLISH, "Check that the defined element does not exist in the web page" )), - ASSERT_CONTENT(ImmutableMap.of( Locale.ENGLISH, "assert content" ,Locale.FRENCH, "contient ?" ), - ImmutableMap.of( Locale.FRENCH, "Vérifie la valeur indiqué est contenu dans l'élement défini" , - Locale.ENGLISH, "Check that the defined element contains the value indicated" )), - ASSERT_NOT_CONTENT(ImmutableMap.of( Locale.ENGLISH, "assert not content" ,Locale.FRENCH, "ne contient pas ?" ), - ImmutableMap.of( Locale.FRENCH, "Vérifie la valeur indiqué est contenu dans l'élement défini" , - Locale.ENGLISH, "Check that the defined element does not contain the value indicated" )), - ASSERT_SELECTED(ImmutableMap.of( Locale.ENGLISH, "assert selected" , Locale.FRENCH, "séléctionné ?"), - ImmutableMap.of( Locale.FRENCH, "Vérifie la valeur indiqué est sélectionnée dans l'élement défini" , - Locale.ENGLISH, "Check that the defined element is selected" )), - ASSERT_NOT_SELECTED(ImmutableMap.of( Locale.ENGLISH, "assert not selected" , Locale.FRENCH, "non séléctionné ?"), - ImmutableMap.of( Locale.FRENCH, "Vérifie que la valeur indiqué n'est pas sélectionnée dans l'élement" , + OPEN(ImmutableMap.of(Locale.ENGLISH, "open", Locale.FRENCH, "ouvrir"), + ImmutableMap.of(Locale.ENGLISH, "Open browser with the given url", + Locale.FRENCH, "Ouverture du navigateur avec l'url indiqué")), + OPEN_PRIVATE(ImmutableMap.of(Locale.ENGLISH, "open private", Locale.FRENCH, "ouvrir en mode privé"), + ImmutableMap.of(Locale.ENGLISH, "Open browser in private mode with the given url", + Locale.FRENCH, "Ouverture du navigateur en mode privé avec l'url indiqué")), + OPEN_TAB(ImmutableMap.of(Locale.ENGLISH, "open tab", Locale.FRENCH, "ouvrir un onglet"), + ImmutableMap.of(Locale.ENGLISH, "Open browser tab with the given url", + Locale.FRENCH, "Ouverture d'un onlget avec l'url indiqué")), + SWITCH_TO(ImmutableMap.of(Locale.ENGLISH, "switch to", Locale.FRENCH, "basculer sur"), + ImmutableMap.of(Locale.ENGLISH, "Switch to tab or window", + Locale.FRENCH, "Basculer sur un onglet ou fenêtre")), + DELETE_COOKIE(ImmutableMap.of(Locale.ENGLISH, "delete cookie", Locale.FRENCH, "supprimer cookie"), + ImmutableMap.of(Locale.ENGLISH, "Delete all cookies", + Locale.FRENCH, "Suppression de tous les cookies")), + CLEAR(ImmutableMap.of(Locale.ENGLISH, "Clear", Locale.FRENCH, "Effacer"), + ImmutableMap.of(Locale.ENGLISH, "Clear the given text field", + Locale.FRENCH, "Effacer le champ texte défini dans la colonne identification")), + SEND_KEYS(ImmutableMap.of(Locale.ENGLISH, "send keys", Locale.FRENCH, "écrire"), + ImmutableMap.of(Locale.ENGLISH, "Send keys to the given text field", + Locale.FRENCH, "Ecriture dans le champ texte défini")), + SEND_KEYS_WITH_CLEAR(ImmutableMap.of(Locale.ENGLISH, "send keys with clear", Locale.FRENCH, "écrire et effacer avant le champ"), + ImmutableMap.of(Locale.ENGLISH, "Send keys with clear to the given text field", + Locale.FRENCH, "Effacer le champ et écrire dans le champ texte défini")), + SEND_KEYS_WITHOUT_ASSERTION(ImmutableMap.of(Locale.ENGLISH, "send keys without assertion", Locale.FRENCH, "écrire sans assertion"), + ImmutableMap.of(Locale.ENGLISH, "Send keys without assertion to the given text field", + Locale.FRENCH, "Ecriture sans assertion dans le champ texte défini")), + CLICK(ImmutableMap.of(Locale.ENGLISH, "click", Locale.FRENCH, "cliquer"), + ImmutableMap.of(Locale.ENGLISH, "Click on the given element", + Locale.FRENCH, "Clic sur l'élément indiqué")), + CLICK_ON_PSEUDO_ELEMENT(ImmutableMap.of(Locale.ENGLISH, "click on pseudo element", Locale.FRENCH, "cliquer sur le pseudo element"), + ImmutableMap.of(Locale.ENGLISH, "Click on the pseudo element of the given element", + Locale.FRENCH, "Clic sur le pseudo element de l'élément indiqué")), + DOUBLE_CLICK(ImmutableMap.of(Locale.ENGLISH, "double click", Locale.FRENCH, "double cliquer"), + ImmutableMap.of(Locale.ENGLISH, "Double click on the given element", + Locale.FRENCH, "Double clic sur l'élément indiqué")), + SELECT(ImmutableMap.of(Locale.ENGLISH, "select", Locale.FRENCH, "séléctionner"), + ImmutableMap.of(Locale.ENGLISH, "Select the given value in the given drop down list", Locale.FRENCH, + "Sélectionne la valeur indiquée dans la liste déroulante définie dans la colonne identification")), + CHECK_BY_VALUE(ImmutableMap.of(Locale.ENGLISH, "Check by value", Locale.FRENCH, "Cocher par la valeur"), + ImmutableMap.of(Locale.ENGLISH, "Check by value for radio ou checkbox", Locale.FRENCH, + "Cocher par la valeur pour un radio ou checkbox")), + CALL(ImmutableMap.of(Locale.ENGLISH, "call", Locale.FRENCH, "appeler"), + ImmutableMap.of(Locale.FRENCH, "Execute le sous-scénario définie dans la colonne Identification", + Locale.ENGLISH, "Execute the sub-scenario defined in the Identification column")), + IF(ImmutableMap.of(Locale.ENGLISH, "if", Locale.FRENCH, "si"), + ImmutableMap.of(Locale.FRENCH, "Si la condition définie dans la colonne des valeurs <<>>,<<>>,etc; les lignes en dessous sont exécutées", + Locale.ENGLISH, "If the condition defined in the values column <<>>,<<>>,etc; the lines below are executed")), + ELSE_IF(ImmutableMap.of(Locale.ENGLISH, "else if", Locale.FRENCH, "sinon si"), + ImmutableMap.of(Locale.FRENCH, "S'éxécute si la condition \"if\" n'est pas respecté. Si la condition définie dans la colonne des valeurs <<>>,<<>>,etc; les lignes en dessous sont exécutées", + Locale.ENGLISH, "Executed if the condition \"if\" is not repected. If the condition defined in the values column <<>>,<<>>,etc; the lines below are executed")), + ELSE(ImmutableMap.of(Locale.ENGLISH, "else", Locale.FRENCH, "sinon"), + ImmutableMap.of(Locale.FRENCH, "Si la condition définie dans le \"if\" au dessus n'est pas respecté, les lignes en dessous sont exécutées", + Locale.ENGLISH, "If the condition defined in the \"if\" above is not respected, the lines below are executed")), + END_IF(ImmutableMap.of(Locale.ENGLISH, "end if", Locale.FRENCH, "fin si") + , ImmutableMap.of(Locale.FRENCH, "Fin d'un bloc \"if\"", + Locale.ENGLISH, "End of an \"if\" block")), + SAVE_DATA(ImmutableMap.of(Locale.ENGLISH, "save data", Locale.FRENCH, "enregistrer"), + ImmutableMap.of(Locale.FRENCH, "Enregistre la valeur définie ou le contenu de l'élément indiqué si la colonne valeur est vide", + Locale.ENGLISH, "Save the defined value or the content of the element indicated if the value column is empty")), + SAVE_DATA_AND_APPLY_REGEX(ImmutableMap.of(Locale.ENGLISH, "save data and apply regex", Locale.FRENCH, "enregistrer et appliquer une regex"), + ImmutableMap.of(Locale.FRENCH, "Enregistre la valeur du contenu de l'élément indiqué et applique une regex", + Locale.ENGLISH, "Save the value of the element content and apply regex")), + ASSERT_EXIST(ImmutableMap.of(Locale.ENGLISH, "assert exist", Locale.FRENCH, "existe ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie que l'élement défini existe dans la page web", + Locale.ENGLISH, "Check that the defined element exists in the web page")), + ASSERT_NOT_EXIST(ImmutableMap.of(Locale.ENGLISH, "assert not exist", Locale.FRENCH, "n'existe pas ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie la valeur indiqué est contenu dans l'élement défini", + Locale.ENGLISH, "Check that the defined element does not exist in the web page")), + ASSERT_CONTENT(ImmutableMap.of(Locale.ENGLISH, "assert content", Locale.FRENCH, "contient ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie la valeur indiqué est contenu dans l'élement défini", + Locale.ENGLISH, "Check that the defined element contains the value indicated")), + ASSERT_NOT_CONTENT(ImmutableMap.of(Locale.ENGLISH, "assert not content", Locale.FRENCH, "ne contient pas ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie la valeur indiqué est contenu dans l'élement défini", + Locale.ENGLISH, "Check that the defined element does not contain the value indicated")), + ASSERT_SELECTED(ImmutableMap.of(Locale.ENGLISH, "assert selected", Locale.FRENCH, "séléctionné ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie la valeur indiqué est sélectionnée dans l'élement défini", + Locale.ENGLISH, "Check that the defined element is selected")), + ASSERT_NOT_SELECTED(ImmutableMap.of(Locale.ENGLISH, "assert not selected", Locale.FRENCH, "non séléctionné ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie que la valeur indiqué n'est pas sélectionnée dans l'élement", Locale.ENGLISH, "Check that the defined element is not selected")), - ASSERT_CHECKED(ImmutableMap.of( Locale.ENGLISH, "assert checked",Locale.FRENCH, "coché ?" ), - ImmutableMap.of( Locale.FRENCH, "Vérifie que l'élement défini est bien coché" , - Locale.ENGLISH, "Check that the defined element is checked" )), - ASSERT_NOT_CHECKED(ImmutableMap.of( Locale.ENGLISH, "assert not checked",Locale.FRENCH, "non coché ?" ), - ImmutableMap.of( Locale.FRENCH, "Vérifie que l'élement défini n'est pas coché" , - Locale.ENGLISH, "Check that the defined element is not checked" )), - SCREENSHOT(ImmutableMap.of( Locale.ENGLISH, "screenshot" , Locale.FRENCH, "capture"), - ImmutableMap.of( Locale.FRENCH, "Effectue une capture d'ecran" , - Locale.ENGLISH, "Take a screenshot" )), - UPLOADFILE(ImmutableMap.of( Locale.ENGLISH, "upload file" , Locale.FRENCH, "choisir fichier"), - ImmutableMap.of( Locale.FRENCH, "Permet d'uploader un fichier présent dans le répertoire nommé Upload lui-même présent au même niveau que le fichier excel" , - Locale.ENGLISH, "Upload a file present in the Upload directory present at the same level as the excel file" )), - POPUP(ImmutableMap.of( Locale.ENGLISH, "accept alert ?" , Locale.FRENCH, "accepter alerte ?"), - ImmutableMap.of( Locale.FRENCH, "permet de gerer les alertes javascript" , - Locale.ENGLISH, "Manage javascript alerts" )), - WAIT(ImmutableMap.of( Locale.ENGLISH, "wait" , Locale.FRENCH, "pause"), - ImmutableMap.of( Locale.FRENCH, "Effectue une pause du temps indiqué en seconde dans la colonne des valeurs" , - Locale.ENGLISH, "Pause for the time indicated in seconds in the value column" )), - SWITCH_FRAME(ImmutableMap.of( Locale.ENGLISH, "switch frame" , Locale.FRENCH, "changer frame"), - ImmutableMap.of( Locale.FRENCH, "Permet de basculer vers une iframe à l'intérieur de la page. Cette iframe doit être définie dans la colonne Target en ID ou XPATH" , - Locale.ENGLISH, "Switch to an iframe inside the page. This iframe must be defined in the Target column in ID or XPATH" )), - EXIT_FRAME(ImmutableMap.of( Locale.ENGLISH, "exit frame" , Locale.FRENCH, "sortir frame"), - ImmutableMap.of( Locale.FRENCH, "Permet de sortir de l'iframe courant" , - Locale.ENGLISH, "Exit the current iframe" )), - END_SCENARIO(ImmutableMap.of(Locale.ENGLISH, "end scenario" , Locale.FRENCH, "fin scenario"), - ImmutableMap.of(Locale.FRENCH, "Indique la fin du scénario courant" , + ASSERT_CHECKED(ImmutableMap.of(Locale.ENGLISH, "assert checked", Locale.FRENCH, "coché ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie que l'élement défini est bien coché", + Locale.ENGLISH, "Check that the defined element is checked")), + ASSERT_NOT_CHECKED(ImmutableMap.of(Locale.ENGLISH, "assert not checked", Locale.FRENCH, "non coché ?"), + ImmutableMap.of(Locale.FRENCH, "Vérifie que l'élement défini n'est pas coché", + Locale.ENGLISH, "Check that the defined element is not checked")), + SCREENSHOT(ImmutableMap.of(Locale.ENGLISH, "screenshot", Locale.FRENCH, "capture"), + ImmutableMap.of(Locale.FRENCH, "Effectue une capture d'ecran", + Locale.ENGLISH, "Take a screenshot")), + FULLSCREENSHOT(ImmutableMap.of(Locale.ENGLISH, "full screenshot", Locale.FRENCH, "capture complète"), + ImmutableMap.of(Locale.FRENCH, "Effectue une capture de l'écran entier", + Locale.ENGLISH, "Take a full desktop screenshot")), + UPLOADFILE(ImmutableMap.of(Locale.ENGLISH, "upload file", Locale.FRENCH, "choisir fichier"), + ImmutableMap.of(Locale.FRENCH, "Permet d'uploader un fichier présent dans le répertoire nommé Upload lui-même présent au même niveau que le fichier excel", + Locale.ENGLISH, "Upload a file present in the Upload directory present at the same level as the excel file")), + POPUP(ImmutableMap.of(Locale.ENGLISH, "accept alert ?", Locale.FRENCH, "accepter alerte ?"), + ImmutableMap.of(Locale.FRENCH, "permet de gerer les alertes javascript", + Locale.ENGLISH, "Manage javascript alerts")), + WAIT(ImmutableMap.of(Locale.ENGLISH, "wait", Locale.FRENCH, "pause"), + ImmutableMap.of(Locale.FRENCH, "Effectue une pause du temps indiqué en seconde dans la colonne des valeurs", + Locale.ENGLISH, "Pause for the time indicated in seconds in the value column")), + SWITCH_FRAME(ImmutableMap.of(Locale.ENGLISH, "switch frame", Locale.FRENCH, "changer frame"), + ImmutableMap.of(Locale.FRENCH, "Permet de basculer vers une iframe à l'intérieur de la page. Cette iframe doit être définie dans la colonne Target en ID ou XPATH", + Locale.ENGLISH, "Switch to an iframe inside the page. This iframe must be defined in the Target column in ID or XPATH")), + EXIT_FRAME(ImmutableMap.of(Locale.ENGLISH, "exit frame", Locale.FRENCH, "sortir frame"), + ImmutableMap.of(Locale.FRENCH, "Permet de sortir de l'iframe courant", + Locale.ENGLISH, "Exit the current iframe")), + END_SCENARIO(ImmutableMap.of(Locale.ENGLISH, "end scenario", Locale.FRENCH, "fin scenario"), + ImmutableMap.of(Locale.FRENCH, "Indique la fin du scénario courant", Locale.ENGLISH, "Indicates the end of the current scenario")), - REFRESH(ImmutableMap.of(Locale.ENGLISH, "refresh" , Locale.FRENCH, "rafraichir"), - ImmutableMap.of(Locale.FRENCH, "Permet de rafraichir la page courante" , + SCROLL_TO_ELEMENT(ImmutableMap.of(Locale.ENGLISH, "scroll to element", Locale.FRENCH, "défiler vers l'élément"), + ImmutableMap.of(Locale.FRENCH, "Permet de défiler vers l'élément indiqué", + Locale.ENGLISH, "Scroll to the indicated element")), + REFRESH(ImmutableMap.of(Locale.ENGLISH, "refresh", Locale.FRENCH, "rafraichir"), + ImmutableMap.of(Locale.FRENCH, "Permet de rafraichir la page courante", Locale.ENGLISH, "Refresh the current page")); final Map commandLibelleMap; @@ -114,7 +141,7 @@ public enum CommandName { @Override public String toString() { return "CommandName : { " + - "Name : " + this.name() + "; " + + "Name : " + this.name() + "; " + "Description : { " + "English : " + this.commandDescriptionMap.get(Locale.ENGLISH) + "; " + "French : " + this.commandDescriptionMap.get(Locale.FRENCH) + " }; " + @@ -125,26 +152,26 @@ public String toString() { } public String toYamlString() { - return "-"+this.name()+":\n" + + return "-" + this.name() + ":\n" + " DESCRIPTION:\n" + - " ENGLISH: " + this.commandDescriptionMap.get(Locale.ENGLISH) + "\n"+ - " FRENCH: " + this.commandDescriptionMap.get(Locale.FRENCH) + "\n"+ + " ENGLISH: " + this.commandDescriptionMap.get(Locale.ENGLISH) + "\n" + + " FRENCH: " + this.commandDescriptionMap.get(Locale.FRENCH) + "\n" + " VALUE:\n" + - " ENGLISH: " + this.commandLibelleMap.get(Locale.ENGLISH) + "\n"+ - " FRENCH: " + this.commandLibelleMap.get(Locale.FRENCH) + "\n" ; + " ENGLISH: " + this.commandLibelleMap.get(Locale.ENGLISH) + "\n" + + " FRENCH: " + this.commandLibelleMap.get(Locale.FRENCH) + "\n"; } public static CommandName fromValue(String value) { - if(StringUtils.isEmpty(value)){ + if (StringUtils.isEmpty(value)) { throw new IllegalArgumentException("La valeur de la commande ne peut pas être vide"); } - for (CommandName commandName: CommandName.values()) { - Optional findValue = commandName.getCommandLibelleMap().values().stream().filter(s -> StringUtil.equalsIgnoreCase(value,s)).findFirst(); - if(findValue.isPresent()){ + for (CommandName commandName : CommandName.values()) { + Optional findValue = commandName.getCommandLibelleMap().values().stream().filter(s -> StringUtil.equalsIgnoreCase(value, s)).findFirst(); + if (findValue.isPresent()) { return commandName; } } - throw new IllegalArgumentException("Cette command n'existe pas : "+value+""); + throw new IllegalArgumentException("Cette command n'existe pas : " + value + ""); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DeleteCookieCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DeleteCookieCommand.java new file mode 100644 index 00000000..d25e6c1d --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DeleteCookieCommand.java @@ -0,0 +1,18 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; +import org.openqa.selenium.WebDriver; + +import java.util.List; + +public class DeleteCookieCommand extends AbstractDriverCommand{ + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ + WebDriver webDriver = getWebDriverToUse(commandResultList); + webDriver.manage().deleteAllCookies(); + } + +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DoubleClickCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DoubleClickCommand.java new file mode 100644 index 00000000..2180a74b --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/DoubleClickCommand.java @@ -0,0 +1,21 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; + +import java.util.List; + +public class DoubleClickCommand extends AbstractDriverCommand { + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { + webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); + executeActionInElement(); + } + + protected void executeActionInElement() throws Exception { + webElementDescription.focusAndDoubleClick(); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ExitFrameCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ExitFrameCommand.java index 45b01c89..31dea180 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ExitFrameCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ExitFrameCommand.java @@ -12,7 +12,7 @@ public class ExitFrameCommand extends AbstractDriverCommand{ @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { - WebDriver driver = getWebDriverToUse(globalApplicationContext,testCaseContext,commandResultList); + WebDriver driver = getWebDriverToUse(commandResultList); if (driver != null) { driver.switchTo().parentFrame(); } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/FullScrenshotCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/FullScrenshotCommand.java new file mode 100644 index 00000000..a380551b --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/FullScrenshotCommand.java @@ -0,0 +1,16 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; + +import java.util.List; + +public class FullScrenshotCommand extends AbstractDriverCommand{ + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ + getScreenshotReportList().add(fullScreenShot(globalApplicationContext,testCaseContext,"",commandResultList)); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/IfCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/IfCommand.java index 6593fc1f..91ead139 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/IfCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/IfCommand.java @@ -4,11 +4,14 @@ import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.AssertContentResult; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; import fr.axa.automation.webengine.util.StringUtil; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import java.util.List; @@ -17,52 +20,46 @@ public class IfCommand extends AbstractDriverCommand { @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { webElementDescription = populateWebElement(globalApplicationContext,testCaseContext, commandData, commandResultList); - String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - if (StringUtils.isEmpty(value)) { + String expectedValue = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + if (StringUtils.isEmpty(expectedValue)) { if (webElementDescription.isNotExists()) { throw new WebEngineException("The element doesn't exist"); } } else { - boolean resultAssert; - if(webElementDescription.isInputSelect()){ - resultAssert = webElementDescription.assertContentByElementType(value); - if (!resultAssert) { - throw new WebEngineException("The element is not selected"); - } - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.CHECKED.getTagValue(), value) && webElementDescription.isInputRadio()){ - resultAssert = webElementDescription.assertContentByElementType(value); - if (!resultAssert) { - throw new WebEngineException("The input radio is not checked"); - } - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_CHECKED.getTagValue(), value) && webElementDescription.isInputRadio()){ - resultAssert = webElementDescription.assertContentByElementType(value); - if (resultAssert) { - throw new WebEngineException("The input radio is checked"); - } - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.EXISTS.getTagValue(), value) && webElementDescription.isNotExists()) { - throw new WebEngineException("The element doesn't exist"); - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_EXISTS.getTagValue(), value) && webElementDescription.exists()) { - throw new WebEngineException("The element exist"); - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.EMPTY.getTagValue(), value)) { - resultAssert = webElementDescription.assertContentByElementType(StringUtils.EMPTY); - if (!resultAssert) { - throw new WebEngineException("The content of the element is not empty"); - } - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_EMPTY.getTagValue(), value)) { - resultAssert = webElementDescription.assertContentByElementType(StringUtils.EMPTY); - if (resultAssert) { - throw new WebEngineException("The content of the element is empty"); - } - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.DISPLAYED.getTagValue(), value) && webElementDescription.isNotDisplayed()) { - throw new WebEngineException("The element is not displayed"); - } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_DISPLAYED.getTagValue(), value) && webElementDescription.isDisplayed()) { - throw new WebEngineException("The element is displayed"); - } else{ - resultAssert = webElementDescription.assertContentByElementType(value); - if (!resultAssert) { - throw new WebEngineException("The value are not the same :" + value); + AssertContentResult assertContentResult; + try{ + if(webElementDescription.isSelect()){ + assertContentResult = webElementDescription.assertContentSelect(expectedValue); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.CHECKED.getTagValue(), expectedValue) && webElementDescription.isInputTypeRadio()){ + assertContentResult = webElementDescription.assertRadioChecked(); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_CHECKED.getTagValue(), expectedValue) && webElementDescription.isInputTypeRadio()){ + assertContentResult = webElementDescription.assertRadioNotChecked(); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.EXISTS.getTagValue(), expectedValue) && webElementDescription.isNotExists()) { + throw new WebEngineException("The element doesn't exist"); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_EXISTS.getTagValue(), expectedValue) && webElementDescription.exists()) { + throw new WebEngineException("The element exist"); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.EMPTY.getTagValue(), expectedValue)) { + assertContentResult = webElementDescription.assertContentEmpty(); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_EMPTY.getTagValue(), expectedValue)) { + assertContentResult = webElementDescription.assertContentNotEmpty(); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.DISPLAYED.getTagValue(), expectedValue) && webElementDescription.isNotDisplayed()) { + throw new WebEngineException("The element is not displayed"); + } else if (StringUtil.equalsIgnoreCase(PredefinedTagValue.NOT_DISPLAYED.getTagValue(), expectedValue) && webElementDescription.isDisplayed()) { + throw new WebEngineException("The element is displayed"); + } else{ + assertContentResult = webElementDescription.assertContentByElementType(expectedValue); } + }catch (Exception e){ + getLogReport().getVariables().add(VariableHelper.getVariable("Cause", e.getMessage())); + getLogReport().getVariables().add(VariableHelper.getVariable("Exception", ExceptionUtils.getStackTrace(e))); + throw new WebEngineException(e.getMessage()); + } + + if(assertContentResult!=null && assertContentResult.isResult()){ + getLogReport().getVariables().add(VariableHelper.getVariable("Expected value", expectedValue)); + getLogReport().getVariables().add(VariableHelper.getVariable("Actual value", assertContentResult.getActualValue())); } + } } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenCommand.java index 58a35805..65c6691a 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenCommand.java @@ -3,43 +3,38 @@ import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.DriverContext; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; -import fr.axa.automation.webengine.helper.CommandResultHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; -import fr.axa.automation.webengine.util.StringUtil; -import fr.axa.automation.webengine.util.UriUtil; -import org.apache.commons.collections4.CollectionUtils; import org.openqa.selenium.WebDriver; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class OpenCommand extends AbstractDriverCommand{ - @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ String url = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - WebDriver webDriver = null; + WebDriver webDriver = instantiateWebDriver(globalApplicationContext, commandResultList); + + DriverContext currentDriverContext = getDriverContext(webDriver, url); - List webDriverList = CommandResultHelper.getWebDriverList(commandResultList); - if(CollectionUtils.isNotEmpty(webDriverList)){//Dans le cas ou l'application a déjà été ouvert, on reutilise le même driver - for ( WebDriver webDriverStored : webDriverList ) { - if(StringUtil.equalsIgnoreCase(webDriverStored.getCurrentUrl(),"data:,") || StringUtil.equalsIgnoreCase(UriUtil.getHostFromURI(webDriverStored.getCurrentUrl()),UriUtil.getHostFromURI(url))){ - webDriver = webDriverStored; - } - } - } - if(webDriver==null) { - webDriver = instantiateWebDrive(globalApplicationContext); - } - setWebDriver(webDriver); - String originalWindow = webDriver.getWindowHandle(); - webDriver.switchTo().window(originalWindow); + setDriverContext(currentDriverContext); + webDriver = currentDriverContext.getWebDriver(); + webDriver.switchTo().window(currentDriverContext.getWindowHandle()); webDriver.manage().window().maximize(); webDriver.navigate().to(url); } - protected WebDriver instantiateWebDrive(AbstractGlobalApplicationContext globalApplicationContext) throws WebEngineException { - return initializeWebDriver(globalApplicationContext); + protected DriverContext getDriverContext(WebDriver webDriver, String url) { + Map sessionIdAndUrlMap = new HashMap<>(); + sessionIdAndUrlMap.put(webDriver.getWindowHandle(), url); + return DriverContext.builder().currentUrl(url).webDriver(webDriver).sessionIdAndUrlMap(sessionIdAndUrlMap).build(); + } + + protected WebDriver instantiateWebDriver(AbstractGlobalApplicationContext globalApplicationContext,List commandResultList) throws WebEngineException { + return initializeWebDriver(globalApplicationContext,false); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenInPrivateModeCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenInPrivateModeCommand.java index 71ce1faf..fbb0a9af 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenInPrivateModeCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenInPrivateModeCommand.java @@ -2,12 +2,15 @@ import fr.axa.automation.webengine.exception.WebEngineException; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.object.CommandResult; import org.openqa.selenium.WebDriver; +import java.util.List; + public class OpenInPrivateModeCommand extends OpenCommand{ @Override - protected WebDriver instantiateWebDrive(AbstractGlobalApplicationContext globalApplicationContext) throws WebEngineException { + protected WebDriver instantiateWebDriver(AbstractGlobalApplicationContext globalApplicationContext, List commandResultList) throws WebEngineException { return initializeIncognitoWebDriver(globalApplicationContext); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenTabCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenTabCommand.java new file mode 100644 index 00000000..9f32da69 --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/OpenTabCommand.java @@ -0,0 +1,49 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.exception.WebEngineException; +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.DriverContext; +import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.CommandResultHelper; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; +import fr.axa.automation.webengine.util.ListUtil; +import org.apache.commons.lang3.StringUtils; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class OpenTabCommand extends OpenCommand { + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { + String url = getValue(globalApplicationContext, (TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + if (StringUtils.isEmpty(url)) { + throw new WebEngineException("you must define a tab url to open a tab"); + } + + DriverContext currentDriverContext = getWebDriverContextFromUrl(commandResultList, url); + + setDriverContext(currentDriverContext); + WebDriver webDriver = currentDriverContext.getWebDriver(); + String windowToSwitch = currentDriverContext.getWindowHandle(); + webDriver.switchTo().window(windowToSwitch); + webDriver.manage().window().maximize(); + webDriver.navigate().to(url); + } + + protected DriverContext getWebDriverContextFromUrl(List commandResultList, String url) throws WebEngineException { + List driverContextList = CommandResultHelper.getWebDriverList(commandResultList); + DriverContext lastDriverContext = ListUtil.getLastElement(driverContextList.stream().collect(Collectors.toList())).get(); + WebDriver webDriver = lastDriverContext.getWebDriver(); + ((JavascriptExecutor) webDriver).executeScript("window.open()"); + + Map sessionIdAndUrlMap = lastDriverContext.getSessionIdAndUrlMap(); + sessionIdAndUrlMap.put(ListUtil.getLastElement(lastDriverContext.getWebDriver().getWindowHandles()).get(),url ); + return DriverContext.builder().currentUrl(url).webDriver(lastDriverContext.getWebDriver()).sessionIdAndUrlMap(sessionIdAndUrlMap).build(); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/PopUpCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/PopUpCommand.java index 4d3b777b..83a0b1eb 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/PopUpCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/PopUpCommand.java @@ -14,7 +14,7 @@ public class PopUpCommand extends AbstractDriverCommand { @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { - WebDriver webDriver = getWebDriverToUse(globalApplicationContext,testCaseContext,commandResultList); + WebDriver webDriver = getWebDriverToUse(commandResultList); String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); if (webDriver != null) { if(StringUtil.equalsIgnoreCase(value, Constant.OUI.getValue()) || StringUtil.equalsIgnoreCase(value, Constant.OK.getValue())){ diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/RefreshCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/RefreshCommand.java index efc6155f..6950de66 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/RefreshCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/RefreshCommand.java @@ -12,7 +12,7 @@ public class RefreshCommand extends AbstractDriverCommand { @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { - WebDriver webDriver = getWebDriverToUse(globalApplicationContext,testCaseContext,commandResultList); + WebDriver webDriver = getWebDriverToUse(commandResultList); if (webDriver != null) { webDriver.navigate().refresh(); }else { diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataAndApplyRegexCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataAndApplyRegexCommand.java new file mode 100644 index 00000000..a1c0acd0 --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataAndApplyRegexCommand.java @@ -0,0 +1,31 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.VariableHelper; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; +import fr.axa.automation.webengine.util.RegexUtil; +import org.apache.commons.collections4.MapUtils; + +import java.util.List; +import java.util.Optional; + +public class SaveDataAndApplyRegexCommand extends AbstractDriverCommand{ + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ + if(MapUtils.isEmpty(commandData.getTargetList())){ + throw new Exception("No target found for command save and apply regex"); + } + webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); + String regex = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + String textInElement = webElementDescription.getTextByElement(); + getLogReport().getVariables().add(VariableHelper.getVariable("Value in element", textInElement)); + Optional textInElementWithRegexOptional = RegexUtil.findFirst(regex,textInElement); + String textInElementAfterApplyRegex = textInElementWithRegexOptional.isPresent() ? textInElementWithRegexOptional.get().toString() : ""; + getLogReport().getVariables().add(VariableHelper.getVariable("Value in element after apply regex", textInElementAfterApplyRegex)); + setSavedData(textInElementAfterApplyRegex); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataCommand.java index 18f9a866..b68e3c17 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SaveDataCommand.java @@ -1,14 +1,11 @@ package fr.axa.automation.webengine.cmd; -import fr.axa.automation.webengine.constante.RegexContante; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; -import fr.axa.automation.webengine.helper.EvaluateValueHelper; +import fr.axa.automation.webengine.helper.VariableHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; -import fr.axa.automation.webengine.util.RegexUtil; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import java.util.List; @@ -18,18 +15,10 @@ public class SaveDataCommand extends AbstractDriverCommand{ @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String dataTestColumName = ((TestCaseNoCodeContext)testCaseContext).getDataTestColumnName(); - String dataToSave = ""; - if(MapUtils.isEmpty(commandData.getTargetList())){ - String value = commandData.getDataTestMap().get(dataTestColumName); - List externalRegexValueList = RegexUtil.match(RegexContante.EXTERNAL_REGEX_VALUE, value); - if(CollectionUtils.isNotEmpty(externalRegexValueList)){ - dataToSave = EvaluateValueHelper.evaluateExternalRegexValue(value,externalRegexValueList,globalApplicationContext.getSettings()); - }else{ - dataToSave = value; - } - }else{ + String dataToSave = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + if(MapUtils.isNotEmpty(commandData.getTargetList())){ dataToSave = webElementDescription.getTextByElement(); + getLogReport().getVariables().add(VariableHelper.getVariable("Value in element", dataToSave)); } setSavedData(dataToSave); } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ScrollToElementCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ScrollToElementCommand.java new file mode 100644 index 00000000..bb0154f9 --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/ScrollToElementCommand.java @@ -0,0 +1,21 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; + +import java.util.List; + +public class ScrollToElementCommand extends AbstractDriverCommand { + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { + webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); + executeActionInElement(); + } + + protected void executeActionInElement() throws Exception { + webElementDescription.scrollToElement(); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysCommand.java index c2c5eb59..ebe8dd7f 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysCommand.java @@ -3,26 +3,35 @@ import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.RobotHelper; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; import org.apache.commons.lang3.StringUtils; import java.util.List; -public class SendKeysCommand extends AbstractDriverCommand{ +public class SendKeysCommand extends AbstractDriverCommand { + + public static final String KEY_ = "KEY_"; + + private final RobotHelper robotHelper = new RobotHelper(); @Override - public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ - webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - executeActionInElement(value); + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { + webElementDescription = populateWebElement(globalApplicationContext, testCaseContext, commandData, commandResultList); + String value = getValue(globalApplicationContext, (TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + executeActionInElement(value, commandData); } - protected void executeActionInElement(String value)throws Exception { - if(value.startsWith("KEY_")){ - webElementDescription.focusAndsendKeyboard(StringUtils.substringAfterLast(value,"KEY_")); - }else{ - webElementDescription.focusAndSendKeys(value); + protected void executeActionInElement(String value, CommandDataNoCode cmdData) throws Exception { + if (cmdData.getTargetList().isEmpty()) { + robotHelper.sendKeys(value); + } else { + if (value.startsWith(KEY_)) { + webElementDescription.sendKeyboard(StringUtils.substringAfterLast(value, KEY_)); + } else { + webElementDescription.sendKeysWithAssertion(value); + } } } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithClearCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithClearCommand.java index 54b9f6de..d5a917d8 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithClearCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithClearCommand.java @@ -1,27 +1,17 @@ package fr.axa.automation.webengine.cmd; -import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; -import fr.axa.automation.webengine.global.AbstractTestCaseContext; -import fr.axa.automation.webengine.global.TestCaseNoCodeContext; import fr.axa.automation.webengine.object.CommandDataNoCode; -import fr.axa.automation.webengine.object.CommandResult; +import org.apache.commons.lang3.StringUtils; -import java.util.List; +public class SendKeysWithClearCommand extends SendKeysCommand{ -public class SendKeysWithClearCommand extends AbstractDriverCommand{ @Override - public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ - webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - String value = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); - executeActionInElement(value); - } - - protected void executeActionInElement(String value)throws Exception { + protected void executeActionInElement(String value, CommandDataNoCode cmdData)throws Exception { if(value.startsWith("KEY_")){ - webElementDescription.focusAndsendKeyboard(value.split("_")[1]); + webElementDescription.sendKeyboard(StringUtils.substringAfterLast(value,"KEY_")); }else{ - webElementDescription.focusAndSendKeysWithClear(value); + webElementDescription.sendKeysWithClearBefore(value); } } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithoutAssertionCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithoutAssertionCommand.java new file mode 100644 index 00000000..ee43a9b7 --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SendKeysWithoutAssertionCommand.java @@ -0,0 +1,16 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.object.CommandDataNoCode; +import org.apache.commons.lang3.StringUtils; + +public class SendKeysWithoutAssertionCommand extends SendKeysCommand{ + + @Override + protected void executeActionInElement(String value, CommandDataNoCode cmdData)throws Exception { + if(value.startsWith("KEY_")){ + webElementDescription.sendKeyboard(StringUtils.substringAfterLast(value,"KEY_")); + }else{ + webElementDescription.sendKeysWithoutAssertion(value); + } + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchFrameCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchFrameCommand.java index f5d10fa5..6d159dbf 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchFrameCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchFrameCommand.java @@ -14,7 +14,7 @@ public class SwitchFrameCommand extends AbstractDriverCommand{ @Override public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList) throws Exception { webElementDescription = populateWebElement(globalApplicationContext,testCaseContext,commandData,commandResultList); - WebDriver webDriver = getWebDriverToUse(globalApplicationContext,testCaseContext,commandResultList); + WebDriver webDriver = getWebDriverToUse(commandResultList); if (webDriver != null) { WebElement webElement = webElementDescription.findElement(); webDriver.switchTo().frame(webElement); diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchToCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchToCommand.java new file mode 100644 index 00000000..4b5cd35c --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/SwitchToCommand.java @@ -0,0 +1,84 @@ +package fr.axa.automation.webengine.cmd; + +import fr.axa.automation.webengine.exception.WebEngineException; +import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; +import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.DriverContext; +import fr.axa.automation.webengine.global.TestCaseNoCodeContext; +import fr.axa.automation.webengine.helper.CommandResultHelper; +import fr.axa.automation.webengine.object.CommandDataNoCode; +import fr.axa.automation.webengine.object.CommandResult; +import fr.axa.automation.webengine.util.ListUtil; +import fr.axa.automation.webengine.util.StringUtil; +import fr.axa.automation.webengine.util.UriUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.openqa.selenium.WebDriver; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class SwitchToCommand extends AbstractDriverCommand{ + + @Override + public void executeCmd(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext, CommandDataNoCode commandData, List commandResultList)throws Exception{ + String id = getValue(globalApplicationContext,(TestCaseNoCodeContext) testCaseContext, commandData, commandResultList); + if(StringUtils.isEmpty(id)){ + throw new WebEngineException("you must define a window id to switch to"); + } + + DriverContext currentDriverContext = getWebDriverContextFromUrl(commandResultList, id); + if(currentDriverContext==null) { + currentDriverContext = getWindowHandlesInDriver(commandResultList, id); + if(currentDriverContext==null) { + throw new WebEngineException("No driver context have found for this id"); + } + } + + setDriverContext(currentDriverContext); + WebDriver webDriver = currentDriverContext.getWebDriver(); + String windowToSwitch = currentDriverContext.getWindowHandle(); + webDriver.switchTo().window(windowToSwitch); + webDriver.manage().window().maximize(); + } + + protected DriverContext getWebDriverContextFromUrl(List commandResultList, String url) throws WebEngineException { + List driverContextList = CommandResultHelper.getWebDriverList(commandResultList); + if (CollectionUtils.isNotEmpty(driverContextList)) { //If application is already open , we use the same driver + for (DriverContext driverContext : driverContextList) { + if (StringUtil.equalsIgnoreCase(UriUtil.getHostFromURI(driverContext.getCurrentUrl()), UriUtil.getHostFromURI(url))) { + return driverContext; + } + } + } + return null; + } + + protected DriverContext getWindowHandlesInDriver(List commandResultList, String urlOrId) throws WebEngineException { + List driverContextList = CommandResultHelper.getWebDriverList(commandResultList); + if (CollectionUtils.isNotEmpty(driverContextList)) { + List driverContextListFilter = driverContextList.stream().filter(currentDriverContext -> currentDriverContext.getWebDriver().getWindowHandles().size() != currentDriverContext.getSessionIdAndUrlMap().size()).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(driverContextListFilter)){ + for (DriverContext currentDriverContext : driverContextList) { + for (Map.Entry entry : currentDriverContext.getSessionIdAndUrlMap().entrySet()) { + if(StringUtil.equalsIgnoreCase(UriUtil.getHostFromURI(entry.getValue()),UriUtil.getHostFromURI(urlOrId))){ + return DriverContext.builder().currentUrl(urlOrId).webDriver(currentDriverContext.getWebDriver()).sessionIdAndUrlMap(currentDriverContext.getSessionIdAndUrlMap()).build(); + } + } + } + }else{ + List webDrivers = driverContextListFilter.stream().map(currentDriverContext -> currentDriverContext.getWebDriver()).distinct().collect(Collectors.toList()); + if (webDrivers.size() > 1) { + throw new WebEngineException("too many drivers context have found"); + } + + DriverContext driverContextFound = driverContextListFilter.get(0); + Map sessionIdAndUrlMap = driverContextFound.getSessionIdAndUrlMap(); + sessionIdAndUrlMap.put(ListUtil.getLastElement(driverContextFound.getWebDriver().getWindowHandles()).get(),urlOrId ); + return DriverContext.builder().currentUrl(urlOrId).webDriver(driverContextFound.getWebDriver()).sessionIdAndUrlMap(sessionIdAndUrlMap).build(); + } + } + return null; + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/UploadFileCommand.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/UploadFileCommand.java index f415e2b1..d79824d3 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/UploadFileCommand.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/cmd/UploadFileCommand.java @@ -38,8 +38,6 @@ private String getFilePath(AbstractGlobalApplicationContext globalApplicationCon } } - - private void uploadLikeImatatingMouse(AbstractGlobalApplicationContext globalApplicationContext, String value) throws AWTException { StringSelection owner = new StringSelection(getFilePath(globalApplicationContext, value)); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(owner,owner); diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/ConstantNoCode.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/ConstantNoCode.java index d36d2988..6e5a3361 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/ConstantNoCode.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/ConstantNoCode.java @@ -21,6 +21,7 @@ public enum ConstantNoCode { MINUS("-"), PLUS("+"), DASH("-"), - CR_LF ("\r\n \r\n"); + CR_LF("\r\n"), + DOUBLE_CR_LF("\r\n \r\n"); final String value; } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedDateTagValue.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedDateTagValue.java index c5b2cce5..a1827aed 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedDateTagValue.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedDateTagValue.java @@ -15,24 +15,25 @@ @Getter @AllArgsConstructor public enum PredefinedDateTagValue implements IPredefinedTag{ + TIMESTAMP("timestamp"), TAG_TODAY ("today"), TAG_TODAY_HOUR ("today_hour"), TAG_YESTERDAY("yesterday"), - TAG_PAST_DAY("pastday"), - TAG_ANTERIOR_DAY("anteriorday"), - TAG_NEXT_DAY("nextday"), - TAG_NEXT_MONTH("nextmonth"), - TAG_ANTERIOR_MONTH("anteriormonth"); + TAG_PAST_DAY("past_day"), + TAG_ANTERIOR_DAY("anterior_day"), + TAG_NEXT_DAY("next_day"), + TAG_NEXT_MONTH("next_month"), + TAG_ANTERIOR_MONTH("anterior_month"); final String tagValue; - public static PredefinedDateTagValue fromTagValue(String v) { + public static PredefinedDateTagValue fromTagValue(String tagValue) { for (PredefinedDateTagValue predefinedDateTagValue : PredefinedDateTagValue.values()) { - if (predefinedDateTagValue.getTagValue().equalsIgnoreCase(v)) { + if (predefinedDateTagValue.getTagValue().equalsIgnoreCase(tagValue)) { return predefinedDateTagValue; } } - throw new IllegalArgumentException(v); + throw new IllegalArgumentException(tagValue); } public static List getDateTagValueList() { diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedTagValue.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedTagValue.java index ccacbec2..ab59d97c 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedTagValue.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/constante/PredefinedTagValue.java @@ -16,11 +16,8 @@ @AllArgsConstructor public enum PredefinedTagValue { EXISTS ("exist"), - NOT_EXISTS ("notExist"), - EMPTY ("empty"), - NOT_EMPTY ("notEmpty"), CHECKED ("checked"), NOT_CHECKED("notChecked"), @@ -29,6 +26,15 @@ public enum PredefinedTagValue { final String tagValue; + public static PredefinedTagValue fromTagValue(String tagValue) { + for (PredefinedTagValue predefinedTagValue : PredefinedTagValue.values()) { + if (predefinedTagValue.getTagValue().equalsIgnoreCase(tagValue)) { + return predefinedTagValue; + } + } + throw new IllegalArgumentException(tagValue); + } + public static List getTagValueList() { return Arrays.asList(PredefinedTagValue.values()).stream().map(predefinedTagValue -> predefinedTagValue.getTagValue()).collect(Collectors.toList()); } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestCaseNoCodeExecutor.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestCaseNoCodeExecutor.java similarity index 96% rename from webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestCaseNoCodeExecutor.java rename to webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestCaseNoCodeExecutor.java index 0ccdff4e..0daab064 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestCaseNoCodeExecutor.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestCaseNoCodeExecutor.java @@ -1,4 +1,4 @@ -package fr.axa.automation.webengine.api; +package fr.axa.automation.webengine.executor; import fr.axa.automation.webengine.core.ITestCaseExecutor; import fr.axa.automation.webengine.exception.WebEngineException; diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestStepNoCodeExecutor.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestStepNoCodeExecutor.java similarity index 93% rename from webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestStepNoCodeExecutor.java rename to webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestStepNoCodeExecutor.java index 6fc2e8ce..b68903e4 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestStepNoCodeExecutor.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestStepNoCodeExecutor.java @@ -1,4 +1,4 @@ -package fr.axa.automation.webengine.api; +package fr.axa.automation.webengine.executor; import fr.axa.automation.webengine.core.ITestStepExecutor; import fr.axa.automation.webengine.exception.WebEngineException; diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestSuiteNoCodeExecutor.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestSuiteNoCodeExecutor.java similarity index 92% rename from webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestSuiteNoCodeExecutor.java rename to webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestSuiteNoCodeExecutor.java index c866dd13..7d62aa82 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/api/ITestSuiteNoCodeExecutor.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/ITestSuiteNoCodeExecutor.java @@ -1,4 +1,4 @@ -package fr.axa.automation.webengine.api; +package fr.axa.automation.webengine.executor; import fr.axa.automation.webengine.core.ITestSuiteExecutor; import fr.axa.automation.webengine.exception.WebEngineException; diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestCaseNoCodeExecutor.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestCaseNoCodeExecutor.java index 1a0edb9a..6241103e 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestCaseNoCodeExecutor.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestCaseNoCodeExecutor.java @@ -1,7 +1,5 @@ package fr.axa.automation.webengine.executor; -import fr.axa.automation.webengine.api.ITestCaseNoCodeExecutor; -import fr.axa.automation.webengine.api.ITestStepNoCodeExecutor; import fr.axa.automation.webengine.cmd.CommandName; import fr.axa.automation.webengine.constante.TargetKey; import fr.axa.automation.webengine.core.AbstractTestCaseWebExecutor; @@ -13,6 +11,7 @@ import fr.axa.automation.webengine.generated.TestCaseReport; import fr.axa.automation.webengine.global.AbstractGlobalApplicationContext; import fr.axa.automation.webengine.global.AbstractTestCaseContext; +import fr.axa.automation.webengine.global.DriverContext; import fr.axa.automation.webengine.global.TestCaseNoCodeContext; import fr.axa.automation.webengine.helper.ActionReportHelper; import fr.axa.automation.webengine.helper.CommandNameHelper; @@ -31,7 +30,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.openqa.selenium.NoSuchSessionException; -import org.openqa.selenium.WebDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -67,10 +65,10 @@ public AbstractTestCaseContext initialize(AbstractGlobalApplicationContext globa public void cleanUp(AbstractGlobalApplicationContext globalApplicationContext, AbstractTestCaseContext testCaseContext,List commandResultList) { try { if(globalApplicationContext.getSettings().isCloseBrowser()){ - List webDriverList = CommandResultHelper.getWebDriverList(commandResultList); - webDriverList.stream().forEach(webDriver -> { - if (webDriver != null) { - webDriver.quit(); + List driverContextList = CommandResultHelper.getWebDriverList(commandResultList); + driverContextList.stream().forEach(driverContext -> { + if (driverContext.getWebDriver() != null) { + driverContext.getWebDriver().quit(); } }); loggerService.info("Browser close properly"); @@ -226,7 +224,7 @@ protected List runTestStep(AbstractGlobalApplicationContext globa ignoredAllNextCmd = isIgnoredAllOtherAction(commandResult); } } catch (Throwable e) { - loggerService.info("Fatal exception during command : " + commandName + " and test case name is : " + testCaseName + ". All commands are cancelled."); + loggerService.error("Fatal exception during command : " + commandName + " and test case name is : " + testCaseName + ". All commands are cancelled.",e); actionReport.setResult(Result.CRITICAL_ERROR); actionReport.setLog(ExceptionUtils.getStackTrace(e)); firstParentCommandResultOnlyList.add(CommandResultHelper.getCommandResult(commandData, actionReport, "")); diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestStepNoCodeExecutor.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestStepNoCodeExecutor.java index a520e0f3..f8365ec5 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestStepNoCodeExecutor.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestStepNoCodeExecutor.java @@ -1,6 +1,5 @@ package fr.axa.automation.webengine.executor; -import fr.axa.automation.webengine.api.ITestStepNoCodeExecutor; import fr.axa.automation.webengine.cmd.AbstractDriverCommand; import fr.axa.automation.webengine.cmd.CommandFactory; import fr.axa.automation.webengine.cmd.ScrenshotCommand; @@ -50,7 +49,7 @@ public CommandResult run(AbstractGlobalApplicationContext globalApplicationConte } return CommandResult.builder().commandData(commandData) .actionReport(commandResult !=null ? commandResult.getActionReport() : actionReport) - .webDriver(commandResult !=null ? commandResult.getWebDriver() : null) + .driverContext(commandResult !=null ? commandResult.getDriverContext() : null) .savedData(commandResult !=null ? commandResult.getSavedData() : "") .build(); } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestSuiteNoCodeExecutor.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestSuiteNoCodeExecutor.java index 2d35e97b..68ed27f1 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestSuiteNoCodeExecutor.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/executor/TestSuiteNoCodeExecutor.java @@ -1,7 +1,5 @@ package fr.axa.automation.webengine.executor; -import fr.axa.automation.webengine.api.ITestCaseNoCodeExecutor; -import fr.axa.automation.webengine.api.ITestSuiteNoCodeExecutor; import fr.axa.automation.webengine.core.AbstractTestSuiteExecutor; import fr.axa.automation.webengine.core.ITestCaseExecutor; import fr.axa.automation.webengine.exception.WebEngineException; @@ -44,6 +42,7 @@ public TestSuiteNoCodeExecutor(@Qualifier("testCaseNoCodeExecutor") ITestCaseExe @Override public TestSuiteReport run(AbstractGlobalApplicationContext globalAppContext, TestSuiteDataNoCode testSuiteData) throws WebEngineException, UnknownHostException { + loggerService.info("Start run test suite "); GlobalApplicationContextNoCode globalApplicationContext = (GlobalApplicationContextNoCode) globalAppContext; Calendar startTime = Calendar.getInstance(); TestSuiteReport testSuiteReport; @@ -58,6 +57,7 @@ public TestSuiteReport run(AbstractGlobalApplicationContext globalAppContext, Te TestSuiteReportInformation testSuiteReportInformation = TestSuiteReportInformation.builder().environmentVariables(null).testCaseReportList(testCaseReportList).startTime(startTime).systemError(systemError).build(); testSuiteReport = TestSuiteReportHelper.getTestSuiteReport(testSuiteReportInformation); } + loggerService.info("End run test suite"); return testSuiteReport; } @@ -96,10 +96,12 @@ private List getTestCaseListToRun(TestSuiteDataNoCode testSu public void deleteTempFile(String dataTestFileName) { + loggerService.info("Start deleting temp file "); try { Files.deleteIfExists(Paths.get(dataTestFileName)); } catch (Exception e) { loggerService.error("Error when deleting temp file : " + dataTestFileName, e); } + loggerService.info("End deleting temp file "); } } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/global/DriverContext.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/global/DriverContext.java new file mode 100644 index 00000000..145745f1 --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/global/DriverContext.java @@ -0,0 +1,32 @@ +package fr.axa.automation.webengine.global; + + +import fr.axa.automation.webengine.exception.WebEngineException; +import fr.axa.automation.webengine.util.StringUtil; +import fr.axa.automation.webengine.util.UriUtil; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.FieldDefaults; +import org.openqa.selenium.WebDriver; + +import java.util.Map; + +@FieldDefaults(level = AccessLevel.PRIVATE) +@Data +@Builder +public class DriverContext { + String currentUrl; + Map sessionIdAndUrlMap; + WebDriver webDriver; + + public String getWindowHandle(){ + return sessionIdAndUrlMap.entrySet().stream().filter(entry -> { + try { + return StringUtil.equalsIgnoreCase(UriUtil.getHostFromURI(entry.getValue()), UriUtil.getHostFromURI(currentUrl)); + } catch (WebEngineException e) { + throw new RuntimeException(e); + } + }).findFirst().get().getKey(); + } +} diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/CommandResultHelper.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/CommandResultHelper.java index 65a16abb..f87b908a 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/CommandResultHelper.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/CommandResultHelper.java @@ -3,10 +3,10 @@ import fr.axa.automation.webengine.cmd.CommandName; import fr.axa.automation.webengine.generated.ActionReport; import fr.axa.automation.webengine.generated.Result; +import fr.axa.automation.webengine.global.DriverContext; import fr.axa.automation.webengine.object.CommandDataNoCode; import fr.axa.automation.webengine.object.CommandResult; import org.apache.commons.collections4.CollectionUtils; -import org.openqa.selenium.WebDriver; import java.util.ArrayList; import java.util.List; @@ -33,12 +33,12 @@ public static List getCommand(List commandResultL .collect(Collectors.toList()); } - public static List getWebDriverList(List commandResultList){ + public static List getWebDriverList(List commandResultList){ List commandResultFlatList = flatCommandResult(commandResultList, new ArrayList<>()); return commandResultFlatList .stream() - .filter(commandResult -> commandResult.getWebDriver()!=null) - .map(commandResult -> commandResult.getWebDriver()) + .filter(commandResult -> commandResult.getDriverContext()!=null) + .map(commandResult -> commandResult.getDriverContext()) .collect(Collectors.toList()); } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/EvaluateValueHelper.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/EvaluateValueHelper.java index 8e4dd8d5..74e9c579 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/EvaluateValueHelper.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/EvaluateValueHelper.java @@ -1,5 +1,6 @@ package fr.axa.automation.webengine.helper; +import com.microsoft.schemas.office.office.STInsetMode; import fr.axa.automation.webengine.constante.ConstantNoCode; import fr.axa.automation.webengine.constante.PredefinedDateTagValue; import fr.axa.automation.webengine.constante.PredefinedTagValue; @@ -114,9 +115,9 @@ public static String getSavedData(String value, List commandResul if(CollectionUtils.isNotEmpty(commandResultList)){ List commandResultFlatList = CommandResultHelper.flatCommandResult(commandResultList,new ArrayList<>()); List saveDataList = commandResultFlatList.stream() - .filter(commandResult -> StringUtil.equalsIgnoreCase(commandResult.getCommandData().getName(),value)) - .map(commandResult -> commandResult.getSavedData()) - .collect(Collectors.toList()); + .filter(commandResult -> StringUtil.equalsIgnoreCase(commandResult.getCommandData().getName(),value)) + .map(commandResult -> commandResult.getSavedData()) + .collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(commandResultList)){ return saveDataList.get(0); } @@ -126,29 +127,48 @@ public static String getSavedData(String value, List commandResul private static String replaceTagDateValue(String value){ String onlyTagValue = getOnlyTagValue(value); + String dateFormat = getFormatForTagValue(value); + if (!StringUtils.isNotEmpty(dateFormat)) { + if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_TODAY_HOUR.getTagValue())) + dateFormat = FormatDate.DDMMYYYYHHMMSS.getFormat(); + { + dateFormat = FormatDate.DDMMYYYY.getFormat(); + } + } + if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_TODAY.getTagValue()) && value.contains(ConstantNoCode.MINUS.getValue())) { - return DateUtil.minusDay(FormatDate.DDMMYYYY,RegexUtil.getNumber(RegexContante.REGEX_NUMBER,value)); + return DateUtil.minusDay(dateFormat,RegexUtil.getNumber(RegexContante.REGEX_NUMBER,value)); } else if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_TODAY.getTagValue()) && value.contains(ConstantNoCode.PLUS.getValue())) { - return DateUtil.addDay(FormatDate.DDMMYYYY,RegexUtil.getNumber(RegexContante.REGEX_NUMBER,value)); + return DateUtil.addDay(dateFormat,RegexUtil.getNumber(RegexContante.REGEX_NUMBER,value)); } else if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_TODAY.getTagValue())) { - return DateUtil.getDateTime(FormatDate.DDMMYYYY); + return DateUtil.getDateTime(dateFormat); }else if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_TODAY_HOUR.getTagValue())) { - return DateUtil.getDateTime(FormatDate.DDMMYYYYHHMM); + return DateUtil.getDateTime(FormatDate.DDMMYYYYHHMMSS); } else if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_ANTERIOR_DAY.getTagValue()) && StringUtil.contains(value, PredefinedDateTagValue.TAG_YESTERDAY.getTagValue())) { - return DateUtil.minusDay(FormatDate.DDMMYYYY,1); + return DateUtil.minusDay(dateFormat,1); }else if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_NEXT_DAY.getTagValue()) && StringUtil.contains(value, PredefinedDateTagValue.TAG_PAST_DAY.getTagValue())) { - return DateUtil.addDay(FormatDate.DDMMYYYY,1); + return DateUtil.addDay(dateFormat,1); } else if (StringUtils.equalsIgnoreCase(onlyTagValue, PredefinedDateTagValue.TAG_NEXT_MONTH.getTagValue())) { - return DateUtil.addMonth(FormatDate.DDMMYYYY,1); + return DateUtil.addMonth(dateFormat,1); }else { return value; } + } private static String getOnlyTagValue(String value) { if(StringUtils.isNotEmpty(value)){ - return Arrays.asList(value.split("[+-]")).get(0); + return value.split(":")[0].split("[+-]")[0]; } return ""; } + + private static String getFormatForTagValue(String value) { + if(StringUtils.isNotEmpty(value) && value.contains(":")){ + return value.substring(value.indexOf(":")+1); + } + return ""; + } + //create unit test code for getFormatForTagValue method + } diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/RobotHelper.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/RobotHelper.java new file mode 100644 index 00000000..4800902a --- /dev/null +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/helper/RobotHelper.java @@ -0,0 +1,50 @@ +package fr.axa.automation.webengine.helper; + +import fr.axa.automation.webengine.cmd.SendKeysCommand; + +import java.awt.*; +import java.awt.datatransfer.StringSelection; +import java.awt.event.KeyEvent; + +public class RobotHelper { + static { + System.setProperty("java.awt.headless", "false"); + } + public RobotHelper() { + } + + public void sendKeys(String value) throws AWTException, IllegalAccessException, NoSuchFieldException { + Robot robot = new Robot(); + if (value.startsWith(SendKeysCommand.KEY_)) { + robot.keyPress((Integer) KeyEvent.class.getField("VK_" + value.substring(4)).get(null)); + robot.delay(500); + } else { + StringSelection owner = new StringSelection(value); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(owner, owner); + + //imitate mouse events like ENTER, CTRL+C, CTRL+VRobot robot = new Robot(); + robot.delay(500); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_V); + robot.keyRelease(KeyEvent.VK_V); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.delay(500); + } + } + + public void writeString(Robot robot, String s) { + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (Character.isUpperCase(c)) { + robot.keyPress(KeyEvent.VK_SHIFT); + } + robot.keyPress(Character.toUpperCase(c)); + robot.keyRelease(Character.toUpperCase(c)); + + if (Character.isUpperCase(c)) { + robot.keyRelease(KeyEvent.VK_SHIFT); + } + } + robot.delay(500); + } +} \ No newline at end of file diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandDataNoCode.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandDataNoCode.java index a3758b54..1bc7b8d3 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandDataNoCode.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandDataNoCode.java @@ -32,8 +32,7 @@ @NoArgsConstructor @AllArgsConstructor public class CommandDataNoCode { - @JsonProperty("uid") - private String uid; + @JsonProperty("name") private String name; @JsonProperty("command") @@ -46,6 +45,8 @@ public class CommandDataNoCode { private String dataTestReference; @JsonProperty("dataTestList") private Map dataTestMap; + @JsonProperty("uid") + private String uid; public boolean isOptional(){ if(this!=null && StringUtils.isNotEmpty(this.getOptional()) && this.getOptional().equalsIgnoreCase(OptionalConstante.OPTIONAL.getValue())){ diff --git a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandResult.java b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandResult.java index 969ee145..c8e46801 100644 --- a/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandResult.java +++ b/webengine-drive-by-excel/src/main/java/fr/axa/automation/webengine/object/CommandResult.java @@ -1,11 +1,11 @@ package fr.axa.automation.webengine.object; import fr.axa.automation.webengine.generated.ActionReport; +import fr.axa.automation.webengine.global.DriverContext; import lombok.AccessLevel; import lombok.Builder; import lombok.Data; import lombok.experimental.FieldDefaults; -import org.openqa.selenium.WebDriver; import java.util.List; @@ -15,7 +15,7 @@ public class CommandResult { CommandDataNoCode commandData; ActionReport actionReport; - WebDriver webDriver; + DriverContext driverContext; String savedData; List subCommandResultList; } diff --git a/webengine-drive-by-excel/src/test/java/fr/axa/automation/webengine/SampleTest.java b/webengine-drive-by-excel/src/test/java/fr/axa/automation/webengine/SampleTest.java index 0edb2c7a..7e56a278 100644 --- a/webengine-drive-by-excel/src/test/java/fr/axa/automation/webengine/SampleTest.java +++ b/webengine-drive-by-excel/src/test/java/fr/axa/automation/webengine/SampleTest.java @@ -19,7 +19,7 @@ public class SampleTest { @BeforeEach // setup() public void setup() throws Exception { - optionalWebdriver = BrowserFactory.getWebDriver("Windows", "Chrome", Arrays.asList("--remote-allow-origins=*")); + optionalWebdriver = BrowserFactory.getWebDriver("Windows", "Chrome",true, Arrays.asList("--remote-allow-origins=*")); } @AfterEach diff --git a/webengine-js/pom.xml b/webengine-js/pom.xml new file mode 100644 index 00000000..c65252ed --- /dev/null +++ b/webengine-js/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + fr.axa.automation.webengine + webengine-parent + 3.1.14 + + + webengine-js + + + 8 + 8 + UTF-8 + + + \ No newline at end of file diff --git a/webengine-js/src/main/resources/js/css-selector-generator.js b/webengine-js/src/main/resources/js/css-selector-generator.js new file mode 100644 index 00000000..49b9fa0f --- /dev/null +++ b/webengine-js/src/main/resources/js/css-selector-generator.js @@ -0,0 +1,24 @@ +function finder(el) { + if (!(el instanceof Element)) + return; + var path = []; + while (el.nodeType === Node.ELEMENT_NODE) { + var selector = el.nodeName.toLowerCase(); + if (el.id) { + selector += '#' + el.id; + path.unshift(selector); + break; + } else { + var sib = el, nth = 1; + while (sib = sib.previousElementSibling) { + if (sib.nodeName.toLowerCase() == selector) + nth++; + } + if (nth != 1) + selector += ":nth-of-type("+nth+")"; + } + path.unshift(selector); + el = el.parentNode; + } + return path.join(" > "); +} \ No newline at end of file diff --git a/webengine-js/src/main/resources/js/global-function.js b/webengine-js/src/main/resources/js/global-function.js new file mode 100644 index 00000000..7c49b73f --- /dev/null +++ b/webengine-js/src/main/resources/js/global-function.js @@ -0,0 +1,7 @@ +function getLastChild(el) { + if (!(el instanceof Element)){ + return null; + } + + return el.lastChild; +} \ No newline at end of file diff --git a/webengine-drive-by-excel/src/main/resources/querySelector.js b/webengine-js/src/main/resources/js/shadow-dom-query-selector.js similarity index 100% rename from webengine-drive-by-excel/src/main/resources/querySelector.js rename to webengine-js/src/main/resources/js/shadow-dom-query-selector.js diff --git a/webengine-report-jacoco-aggregate/pom.xml b/webengine-report-jacoco-aggregate/pom.xml index bac20022..f13168f5 100644 --- a/webengine-report-jacoco-aggregate/pom.xml +++ b/webengine-report-jacoco-aggregate/pom.xml @@ -5,11 +5,10 @@ fr.axa.automation.webengine webengine-parent - 3.0.11 + 3.1.14 webengine-report-jacoco-aggregate - 3.0.11 jar webengine-report-jacoco-aggregate diff --git a/webengine-report/pom.xml b/webengine-report/pom.xml index 6a6c0323..9c247330 100644 --- a/webengine-report/pom.xml +++ b/webengine-report/pom.xml @@ -3,12 +3,11 @@ webengine-parent fr.axa.automation.webengine - 3.0.11 + 3.1.14 4.0.0 webengine-report - 3.0.11 jar webengine-report diff --git a/webengine-report/src/main/java/fr/axa/automation/webengine/report/helper/global/ReportHelper.java b/webengine-report/src/main/java/fr/axa/automation/webengine/report/helper/global/ReportHelper.java index bb5dbba4..05f74abf 100644 --- a/webengine-report/src/main/java/fr/axa/automation/webengine/report/helper/global/ReportHelper.java +++ b/webengine-report/src/main/java/fr/axa/automation/webengine/report/helper/global/ReportHelper.java @@ -39,11 +39,13 @@ public ReportHelper(IWebengineXmlReportHelper webengineReportHelper, IWebengineH } public Map generateReports(TestSuiteReport testSuiteReport, String testSuiteName, String outputPath) throws WebEngineException { + loggerService.info("Start report "); TestSuiteReport testSuiteReportCopy = TestSuiteReportHelper.clone(testSuiteReport); Map path = new HashMap<>(); path.put(ReportPathKey.XML_REPORT_PATH_KEY,generateWebengineXmlReport(testSuiteReportCopy, outputPath)); path.put(ReportPathKey.HTML_REPORT_PATH_KEY,generateWebengineHtmlReport(testSuiteReportCopy, outputPath,path.get(ReportPathKey.XML_REPORT_PATH_KEY))); path.put(ReportPathKey.JUNIT_REPORT_PATH_KEY,generateJunitReport(testSuiteReportCopy, testSuiteName, outputPath)); + loggerService.info("End report "); return path; } @@ -66,7 +68,8 @@ public String generateWebengineHtmlReport(TestSuiteReport testSuiteReport, Strin } public void openReport(String reportPath) throws WebEngineException { - loggerService.info("Start Opening Report"); + loggerService.info("Start opening report"); ApplicationDesktop.openDefaultBrowser(reportPath); + loggerService.info("End opening report "); } } \ No newline at end of file diff --git a/webengine-report/src/main/resources/html-report/assets/css/badge.css b/webengine-report/src/main/resources/html-report/assets/css/badge.css index 56eb6475..672b429f 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/badge.css +++ b/webengine-report/src/main/resources/html-report/assets/css/badge.css @@ -7,34 +7,46 @@ transition: 200ms all ease-in-out; } -.badge-action { +.badge-action, +.badge-action-azur-mist, +.badge-action-white-ecru, +.badge-action-pink, +.badge-action-gray, +.badge-action-green, +.badge-action-red, +.badge-action-violet{ display: inline-block; background-color: #00008f !important; - color: white; + color: black !important; font-weight: 350 !important; font-size: 16px !important; padding: 0.8em 1.5em !important; - border-radius: 30px !important; } -.badge-action-green { - color: #27ae60 !important; +.badge-action-azur-mist { + background-color: #F0FFFF !important; } -.badge-action-red { - color: #e74c3c !important; +.badge-action-white-ecru { + background-color: #FEFEE0 !important; } -.badge-action-blue { - color: #3498db !important; +.badge-action-pink { + background-color: #FEE7F0 !important; } .badge-action-gray { - color: #ccd1d1 !important; + background-color: #EFEFEF !important; +} + +.badge-action-green { + background-color: #c8f4d5 !important; +} + +.badge-action-red { + background-color: #f7cecb !important; } -.badge-action-hover:hover { - cursor: pointer; - background-color: white !important; - color: gray !important; +.badge-action-violet { + background-color: #e5e5fd !important; } diff --git a/webengine-report/src/main/resources/html-report/assets/css/body-content.css b/webengine-report/src/main/resources/html-report/assets/css/body-content.css index faa6311b..a09512a7 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/body-content.css +++ b/webengine-report/src/main/resources/html-report/assets/css/body-content.css @@ -14,7 +14,8 @@ height: 100%; background-color: white; position: relative; - border: 1px solid #e7e9eb; + /*border: 1px solid #e7e9eb;*/ + border-right: 2px solid #e7e9eb; } .body-right-container { @@ -26,10 +27,9 @@ width: 60%; background-color: white; position: relative; - margin-left: 20px; - border: 1px solid #e7e9eb; + /*border: 1px solid #e7e9eb;*/ } -.body-right-container-class { +.body-right-container-class { /* don't delete, its' use by javascript*/ } diff --git a/webengine-report/src/main/resources/html-report/assets/css/content-view.css b/webengine-report/src/main/resources/html-report/assets/css/content-view.css index 09d9f98a..7a88a29d 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/content-view.css +++ b/webengine-report/src/main/resources/html-report/assets/css/content-view.css @@ -1,7 +1,7 @@ .content-header-container { width: 100%; - height: 8%; - margin-bottom: 1em; + height: 50px; + /*margin-bottom: 1em;*/ } .content-container{ diff --git a/webengine-report/src/main/resources/html-report/assets/css/global.css b/webengine-report/src/main/resources/html-report/assets/css/global.css index 205150d1..a0389775 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/global.css +++ b/webengine-report/src/main/resources/html-report/assets/css/global.css @@ -15,8 +15,8 @@ body { margin: 0; background: #fff; /* font-family: Source Sans Pro, sans-serif; */ - font-family: "Raleway"; - font-size: 14px !important; + font-family: Arial, Helvetica, sans-serif !important; + font-size: 15px !important; height: 100%; width: 100%; } @@ -36,9 +36,7 @@ section { } .common-font { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, - "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", - "Segoe UI Symbol", "Noto Color Emoji"; + font-family: Arial, Helvetica, sans-serif !important; font-weight: 600; line-height: 2; color: #515a5a; @@ -48,14 +46,8 @@ section { color: #f1948a; } -.shadow { - -webkit-box-shadow: 10px 11px 5px 0px rgba(0, 0, 0, 0.1); - -moz-box-shadow: 10px 11px 5px 0px rgba(0, 0, 0, 0.1); - box-shadow: 10px 11px 5px 0px rgba(0, 0, 0, 0.1); -} - .selected-line { - color: #00008f !important; + color: black !important; font-weight: bold; } @@ -65,25 +57,48 @@ a { background-color: transparent !important; } -/* ***********************scrollbar*********************** */ -/* width */ -::-webkit-scrollbar { - width: 10px; +.dot,.dot-stat, +.dot-stat-green, +.dot-stat-red, +.dot-stat-gray{ + height: 25px; + width: 25px; + background-color: #bbb; + border-radius: 50%; + justify-content: center; + align-items: center; + padding-top: 2px; + display: flex; +} + +.dot-stat,.dot-stat-green, +.dot-stat-red, +.dot-stat-gray{ + height: 40px; + width: 40px; } -/* Track */ -::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px grey; +.dot-stat-green { + background-color: #c8f4d5; + margin-right: 5px; } -/* Handle */ -::-webkit-scrollbar-thumb { - background: #00008f; +.dot-stat-red{ + background-color: rgb(247, 206, 203); + margin-right: 5px; +} + +.dot-stat-gray{ + background-color: #e6e6e6; +} + + +.container-info{ + margin-bottom: 30px; } -/* Handle on hover */ -::-webkit-scrollbar-thumb:hover { - background: #00008f; +h6{ + margin-bottom: 30px!important; } /* ***********************footer*********************** */ @@ -98,7 +113,6 @@ footer { } /* ***********************Responsive*********************** */ - @media (max-width: 640px) { body { min-height: 0; @@ -116,4 +130,21 @@ footer { width: auto; order: 1; } +} + +.icon-green{ + color:green; +} + +.icon-red{ + color:red; +} + +.icon-gray{ + color:gray; +} + +.icon-around{ + margin-left: 5px; + margin-right: 5px; } \ No newline at end of file diff --git a/webengine-report/src/main/resources/html-report/assets/css/header.css b/webengine-report/src/main/resources/html-report/assets/css/header.css index dddafbeb..01a6c903 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/header.css +++ b/webengine-report/src/main/resources/html-report/assets/css/header.css @@ -1,16 +1,15 @@ .site-header { display: flex; align-items: center; - justify-content: center; + justify-content: flex-start; flex-grow: 1; - height: 10%; - padding: 20px; - box-shadow: 0 1px 6px 0 rgba(32, 33, 36, 0.28); - background-color: #00008f; + height: 100px; + padding: 0 32px; + background-color: #000; } .site-header .fa-registered { - color: white; + color: #f32222; } .site-header-section { @@ -45,15 +44,23 @@ flex-direction: row; justify-content: center; align-items: center; + margin-top: 10px; + margin-bottom: 10px; } .information-sub-header, .chart-header { display: flex; flex-wrap: wrap; - justify-content: center; + justify-content: flex-start; align-items: center; height: auto; padding: 0px; - color: gray; background-color: white; flex-grow: 1; -} \ No newline at end of file + margin: 5px; +} + +.stat-header{ + display: flex; + justify-content: flex-end; + flex: 1; +} diff --git a/webengine-report/src/main/resources/html-report/assets/css/tab.css b/webengine-report/src/main/resources/html-report/assets/css/tab.css index f46b1797..f30ccdb8 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/tab.css +++ b/webengine-report/src/main/resources/html-report/assets/css/tab.css @@ -2,35 +2,36 @@ flex-grow: 1; width: 100%; height: 100%; - color: #ffffff; + color: black; font-weight: 500; font-size: 1.2em; cursor: pointer; padding: 8px 16px !important; margin-bottom: 0px; - border-bottom: #D5D8DC 6px solid !important; + border-bottom: #D5D8DC 2px solid !important; } .tab-bar { display: flex; width: 100%; height: 100%; - background-color: #00008f; + background-color: #ffffff; } .tab-label:hover { - color: #00008f !important; + color: black !important; background-color: #ffffff !important; - border-bottom: #00008f 6px solid !important; + border-bottom: black 2px solid !important; } .tab-content-container { width: 100%; - padding: 10px; + padding-left: 10px; + padding-top: 10px; } .tab-content-log-container { - white-space: pre-line; + white-space: normal; } .container-img { @@ -48,12 +49,11 @@ } .w3-border-blue,.w3-hover-border-blue:hover { - border-color: #00008f !important; + border-color: black !important; background-color: #ffffff; - color: #00008f; + color: black; } .tab-content-container.class-container-tab h6 { - color: #00008f !important; font-weight: 700 !important; } .border-div { diff --git a/webengine-report/src/main/resources/html-report/assets/css/table.css b/webengine-report/src/main/resources/html-report/assets/css/table.css index 6d1d56f2..1153a9e6 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/table.css +++ b/webengine-report/src/main/resources/html-report/assets/css/table.css @@ -1,31 +1,30 @@ -.table-common { - width: 100%!important; - border: 1px solid #E5E7E9; +#table-common { + font-family: Arial, Helvetica, sans-serif; + border-collapse: collapse; + width: 100%; } -.table-common th{ - text-align: left; - vertical-align: middle; - /*border-bottom: 1px solid #E5E7E9;*/ - color:#273746!important; - border: 1px solid #E5E7E9; - padding-left: 5px!important; +#table-common td, #table-common th { + border: 1px solid #ddd; + padding: 8px; } -.table-common tr{ - height: 50px; +#table-common td.name { + width: 30%; } -th{ - text-align: start; - padding-left: 0px!important; - padding-right: 0px!important; +#table-common td.value { + width: 70%; } -td{ - vertical-align: middle!important; - padding-left: 5px!important; - padding-right: 5px!important; - word-break: break-all; - border: 1px solid #E5E7E9; -} +#table-common tr:nth-child(even){background-color: #f2f2f2;} + +#table-common tr:hover {background-color: #ddd;} + +#table-common th { + padding-top: 12px; + padding-bottom: 12px; + text-align: left; + background-color: #eaeaea; + color: black; +} \ No newline at end of file diff --git a/webengine-report/src/main/resources/html-report/assets/css/tree.css b/webengine-report/src/main/resources/html-report/assets/css/tree.css index 7360f72b..641f8976 100644 --- a/webengine-report/src/main/resources/html-report/assets/css/tree.css +++ b/webengine-report/src/main/resources/html-report/assets/css/tree.css @@ -2,16 +2,17 @@ display: flex; flex-direction: row; width: 100%; - background-color: #00008f; + /*background-color: #000;*/ padding: 1em; - margin-bottom: 1em; + /*margin-bottom: 1em;*/ width: 100%; - height: 8%; + height: 50px; + border-bottom: 2px solid #e7e9eb } .tree-header-container h1 { font-size: 1.3em; - color: white; + color: black; margin-bottom: 0; } @@ -26,76 +27,103 @@ } .tree-one-action-container { - align-content: center; - align-items: center; - display: flex; margin-right: 8px; } .icon-action-tree{ - color: white; + color: black; cursor: pointer; } .tree-container{ width: 100%; - height: 90%; + height: 95%; overflow: auto; background-color: #ffffff; } -ul, #idTree { - list-style-type: none; + +ul.tree{ + padding-left: 0px; + padding-top: 5px; } -#idTree { - margin: 10px; - padding: 0; - width: 100%; +.tree { + --spacing: 1.5rem; + --radius: 10px; + --marker-bg-default: #eaeaea; + --marker-bg-haschild: #eaeaea; + line-height: 2rem; } -#idTree li { - transition: 200ms all ease-in-out; - font-family: 'Poppins' !important; - font-size: 1em !important; +.tree li { + display: block; + position: relative; + padding-left: calc(2 * var(--spacing) - var(--radius) - 2px); } - -#idTree li:hover { - transform: scale(1.02); +.tree ul { + margin-left: calc(var(--radius) - var(--spacing)); + padding-left: 0; } - -.caret { +.tree a{ cursor: pointer; - -webkit-user-select: none; /* Safari 3.1+ */ - -moz-user-select: none; /* Firefox 2+ */ - -ms-user-select: none; /* IE 10+ */ - user-select: none; - font-size: 1.1em!important; } -#idTree .badge-action-red, -#idTree .badge-action-green { - font-size: 1.5em; +.tree ul li { + border-left: 2px solid #ddd; } - - - -.caret::before { - content: "\25B7"; - color: black; - display: inline-block; - margin-right: 6px; +.tree ul li:last-child { + border-color: transparent; } -.caret-down::before { - -ms-transform: rotate(90deg); /* IE 9 */ - -webkit-transform: rotate(90deg); /* Safari */' -transform: rotate(90deg); +.tree ul li::before{ + content: ''; + display: block; + position: absolute; + top: calc(var(--spacing) / -2); + left: -2px; + width: calc(var(--spacing) + 2px); + height: calc(var(--spacing) + 1px); + border: solid #eaeaea; + border-width: 0 0 2px 2px; } -.nested { +.tree summary { + display: block; + cursor: pointer; + color: black; +} +.tree summary::marker, +.tree summary::-webkit-details-marker { display: none; } +.tree summary:focus { + outline: none; +} +.tree summary:focus-visible { + outline: 1px dotted #000; +} -.active { +.tree li::after, +.tree summary::before { + content: ''; display: block; + position: absolute; + top: calc(var(--spacing) / 2 - var(--radius) + 2px); + left: calc(var(--spacing) - var(--radius) - 2px); + width: calc(2 * var(--radius)); + height: calc(2 * var(--radius)); + border-radius: 50%; + background: var(--marker-bg-default); +} + +.tree summary::before { + content: '+'; + z-index: 1; + background: var(--marker-bg-haschild); + color: black; + line-height: calc(2 * var(--radius)); + text-align: center; +} +.tree details[open] > summary::before { + content: '−'; } diff --git a/webengine-report/src/main/resources/html-report/assets/js/global.js b/webengine-report/src/main/resources/html-report/assets/js/global.js index db565769..fee3bd98 100644 --- a/webengine-report/src/main/resources/html-report/assets/js/global.js +++ b/webengine-report/src/main/resources/html-report/assets/js/global.js @@ -81,19 +81,16 @@ function displayImage(imgToDisplay){ }; } - function expandAll() { - let toggler = document.getElementsByClassName("caret"); + let toggler = document.getElementsByTagName("details"); for (const togglerElement of toggler) { - togglerElement.parentElement.querySelector(".nested").classList.add("active"); - togglerElement.classList.add("caret-down"); + togglerElement.setAttribute("open", ""); } } function collapseAll() { - let toggler = document.getElementsByClassName("caret"); + let toggler = document.getElementsByTagName("details"); for (const togglerElement of toggler) { - togglerElement.parentElement.querySelector(".nested").classList.remove("active"); - togglerElement.classList.remove("caret-down"); + togglerElement.removeAttribute("open"); } } \ No newline at end of file diff --git a/webengine-report/src/main/resources/html-report/xslt/header/header-template.xslt b/webengine-report/src/main/resources/html-report/xslt/header/header-template.xslt index 85787c17..161a0df5 100644 --- a/webengine-report/src/main/resources/html-report/xslt/header/header-template.xslt +++ b/webengine-report/src/main/resources/html-report/xslt/header/header-template.xslt @@ -1,8 +1,29 @@ - +

Webengine report viewer

+
+
+ +
+
+ + +
+
+ +
+
\ No newline at end of file diff --git a/webengine-report/src/main/resources/html-report/xslt/header/sub-header-template.xslt b/webengine-report/src/main/resources/html-report/xslt/header/sub-header-template.xslt index 638b51f3..13bb398a 100644 --- a/webengine-report/src/main/resources/html-report/xslt/header/sub-header-template.xslt +++ b/webengine-report/src/main/resources/html-report/xslt/header/sub-header-template.xslt @@ -1,36 +1,33 @@ -
- Test suite -
- Start time : + Start time :
- End time : + End time :
- Hostname : + Hostname :
- Number of test case : + Number of test case :
- Passed tests : + Passed tests :
- Failed tests : + Failed tests :
- Ignored tests : + Ignored tests :
diff --git a/webengine-report/src/main/resources/html-report/xslt/index.xslt b/webengine-report/src/main/resources/html-report/xslt/index.xslt index 8642b147..acd8ca64 100644 --- a/webengine-report/src/main/resources/html-report/xslt/index.xslt +++ b/webengine-report/src/main/resources/html-report/xslt/index.xslt @@ -39,9 +39,11 @@
+
diff --git a/webengine-report/src/main/resources/html-report/xslt/panel-left/panel-left-template.xslt b/webengine-report/src/main/resources/html-report/xslt/panel-left/panel-left-template.xslt index c3a7760a..dedab6a3 100644 --- a/webengine-report/src/main/resources/html-report/xslt/panel-left/panel-left-template.xslt +++ b/webengine-report/src/main/resources/html-report/xslt/panel-left/panel-left-template.xslt @@ -1,31 +1,33 @@ - + -
    +
    • - +
      + - - - - - + + + +
      +
      @@ -41,25 +43,30 @@

      Test cases

-
-
+
+ +
+
+ +
-
    +
    • - +
      + - - - - + + + +
    diff --git a/webengine-report/src/main/resources/html-report/xslt/panel-left/status-template.xslt b/webengine-report/src/main/resources/html-report/xslt/panel-left/status-template.xslt index ee743060..74d83c1c 100644 --- a/webengine-report/src/main/resources/html-report/xslt/panel-left/status-template.xslt +++ b/webengine-report/src/main/resources/html-report/xslt/panel-left/status-template.xslt @@ -1,20 +1,45 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + - - + \ No newline at end of file diff --git a/webengine-report/src/main/resources/html-report/xslt/panel-right/content-tab/content-tab-information-template.xslt b/webengine-report/src/main/resources/html-report/xslt/panel-right/content-tab/content-tab-information-template.xslt index 11e00933..5c54d01c 100644 --- a/webengine-report/src/main/resources/html-report/xslt/panel-right/content-tab/content-tab-information-template.xslt +++ b/webengine-report/src/main/resources/html-report/xslt/panel-right/content-tab/content-tab-information-template.xslt @@ -2,17 +2,30 @@