From 223076ea6136bec920344d98df886a587858e9b5 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Mon, 26 Aug 2019 19:37:43 +0300 Subject: [PATCH 01/25] fixed issue with findElements method for elements in the specific state updated test because of changes additionally added QuickStartExample and reference to it from README file pom updated with list of developers --- README.md | 28 +++++++++++-------- pom.xml | 22 +++++++++++++-- .../selenium/elements/ElementFactory.java | 13 +++++++-- src/main/resources/localization/en.json | 3 +- src/main/resources/localization/ru.json | 3 +- .../integration/HiddenElementsTests.java | 1 - .../tests/usecases/QuickStartExample.java | 26 +++++++++++++++++ 7 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 src/test/java/tests/usecases/QuickStartExample.java diff --git a/README.md b/README.md index eea226c..f2007c1 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,15 @@ We use interfaces where is possible, so you can implement your own version of ta 1. To start work with this package, simply add the dependency to your pom.xml: ``` - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://repo1.maven.org/maven2/ - - + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://repo1.maven.org/maven2/ + + com.github.aquality-automation @@ -39,17 +39,19 @@ Browser browser = BrowserManager.getBrowser(); ```java browser.maximize(); browser.goTo("https://wikipedia.org"); -browser.waitForPageToLoad() +browser.waitForPageToLoad(); ``` 4. Use ElementFactory class's methods to get an instance of each element. ```java -ITextBox txbEmail = new ElementFactory().getTextBox(By.id("email_create"), "Email"); +ElementFactory elementFactory = new ElementFactory(); +ITextBox txbSearch = elementFactory.getTextBox(By.id("searchInput"), "Search"); + ``` 5. Call element's methods to perform action with element: ```java -txbEmail.type("email@domain.com"); +txbSearch.type("quality assurance"); ``` 6. Quit browser at the end @@ -57,6 +59,8 @@ txbEmail.type("email@domain.com"); browser.quit(); ``` +See full example [here](./src/test/java/tests/usecases/QuickStartExample.java) + ### Documentation To get more details please look at documentation: - [In English](./Documentation.en.md) diff --git a/pom.xml b/pom.xml index edef694..848b41e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.aquality-automation aquality-selenium - 1.1 + 1.1.1 jar Aquality Selenium @@ -45,8 +45,24 @@ - aquality-automation - aquality-automation + DmitryBogatko + Dmitry Bogatko + + + pavelanihimovsky + Pavel Anihimovsky + + + Nikikuzi + Nikita Kuznetsov + + + mialeska + Alaksiej Mialeška + + + sunigos + Igor Sontsa diff --git a/src/main/java/aquality/selenium/elements/ElementFactory.java b/src/main/java/aquality/selenium/elements/ElementFactory.java index 000e4bf..6d60f52 100644 --- a/src/main/java/aquality/selenium/elements/ElementFactory.java +++ b/src/main/java/aquality/selenium/elements/ElementFactory.java @@ -4,6 +4,7 @@ import aquality.selenium.browser.BrowserManager; import aquality.selenium.browser.JavaScript; import aquality.selenium.configuration.Configuration; +import aquality.selenium.configuration.ITimeoutConfiguration; import aquality.selenium.elements.interfaces.*; import aquality.selenium.localization.LocalizationManager; import aquality.selenium.logger.Logger; @@ -101,18 +102,22 @@ private List findElementsCore(By locator, IElementSuppl List elements = new ArrayList<>(); switch (count) { case ZERO: + ConditionalWait.waitFor(driver -> driver.findElements(locator).isEmpty(), + String.format(LocalizationManager.getInstance().getValue("loc.elements.found.but.should.not"), + locator.toString())); break; case MORE_THEN_ZERO: ConditionalWait.waitFor(driver -> !driver.findElements(locator).isEmpty(), String.format(LocalizationManager.getInstance().getValue("loc.no.elements.found.in.state"), locator.toString(), state.toString(), - Configuration.getInstance().getTimeoutConfiguration().getCondition())); + getTimeoutConfig())); break; default: throw new IllegalArgumentException("No such expected value:".concat(count.toString())); } - List webElements = getBrowser().getDriver().findElements(locator); + + List webElements = ElementFinder.getInstance().findElements(locator, getTimeoutConfig().getCondition(), state); int index = 1; for (WebElement webElement : webElements) { try { @@ -180,5 +185,9 @@ private Type convertElementClassToType(Class clazz){ private Browser getBrowser(){ return BrowserManager.getBrowser(); } + + private ITimeoutConfiguration getTimeoutConfig(){ + return Configuration.getInstance().getTimeoutConfiguration(); + } } diff --git a/src/main/resources/localization/en.json b/src/main/resources/localization/en.json index 85bc2df..e2266b8 100644 --- a/src/main/resources/localization/en.json +++ b/src/main/resources/localization/en.json @@ -63,5 +63,6 @@ "loc.waitnotexists" : "Wait until element does not exist in DOM during %1$s seconds", "loc.no.elements.found.in.state" : "no elements with locator '%1$s' found in state '%2$s' during %3$s seconds", "loc.no.elements.found.by.locator" : "No elements were found by locator '%1$s'", - "loc.elements.were.found.but.not.in.state" : "Elements were found by locator '%1$s'. But %2$s" + "loc.elements.were.found.but.not.in.state" : "Elements were found by locator '%1$s'. But %2$s", + "loc.elements.found.but.should.not": "No elements should be found by locator '%1$s'" } \ No newline at end of file diff --git a/src/main/resources/localization/ru.json b/src/main/resources/localization/ru.json index 2cedf91..bdb5c94 100644 --- a/src/main/resources/localization/ru.json +++ b/src/main/resources/localization/ru.json @@ -63,5 +63,6 @@ "loc.waitnotexists" : "Ожидаем исчезновения элемента из DOM в течении %1$s", "loc.no.elements.found.in.state" : "не удалось найти элементов по локатору '%1$s' в состоянии '%2$s' на протяжении %3$s секунд", "loc.no.elements.found.by.locator" : "Не удалось найти элементов по локатору '%1$s'", - "loc.elements.were.found.but.not.in.state" : "Удалось найти элементы по локатору '%1$s'. Но %2$s" + "loc.elements.were.found.but.not.in.state" : "Удалось найти элементы по локатору '%1$s'. Но %2$s", + "loc.elements.found.but.should.not": "Не должно быть найдено элементов по локатору '%1$s'" } \ No newline at end of file diff --git a/src/test/java/tests/integration/HiddenElementsTests.java b/src/test/java/tests/integration/HiddenElementsTests.java index 8dda321..ecf54f6 100644 --- a/src/test/java/tests/integration/HiddenElementsTests.java +++ b/src/test/java/tests/integration/HiddenElementsTests.java @@ -38,6 +38,5 @@ public void testHiddenElementsExist() { public void testNotHiddenElementsNotDisplayed() { List listElements = new SliderForm().getListElements(ElementState.DISPLAYED, ElementsCount.MORE_THEN_ZERO); Assert.assertFalse(listElements.isEmpty()); - Assert.assertFalse(listElements.stream().anyMatch(label -> label.state().waitForDisplayed(1L))); } } diff --git a/src/test/java/tests/usecases/QuickStartExample.java b/src/test/java/tests/usecases/QuickStartExample.java new file mode 100644 index 0000000..c0a73fe --- /dev/null +++ b/src/test/java/tests/usecases/QuickStartExample.java @@ -0,0 +1,26 @@ +package tests.usecases; + +import aquality.selenium.browser.Browser; +import aquality.selenium.browser.BrowserManager; +import aquality.selenium.elements.ElementFactory; +import aquality.selenium.elements.interfaces.ITextBox; +import org.openqa.selenium.By; +import org.testng.annotations.Test; + +public class QuickStartExample { + + @Test + public void test(){ + Browser browser = BrowserManager.getBrowser(); + + browser.maximize(); + browser.goTo("https://wikipedia.org"); + browser.waitForPageToLoad(); + + ElementFactory elementFactory = new ElementFactory(); + ITextBox txbSearch = elementFactory.getTextBox(By.id("searchInput"), "Search"); + txbSearch.type("quality assurance"); + + browser.quit(); + } +} From dee9b1408244ea587f82467d827065a6bd75dd8a Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Tue, 27 Aug 2019 19:08:05 +0300 Subject: [PATCH 02/25] removed repositories section from readme added additional waitForPageToLoad after search in QuickStart example corrected messages in dictionary to get more clean message --- README.md | 13 +------------ src/main/resources/localization/en.json | 2 +- src/main/resources/localization/ru.json | 2 +- src/test/java/tests/usecases/QuickStartExample.java | 1 + 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f2007c1..c4c9c7d 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,6 @@ We use interfaces where is possible, so you can implement your own version of ta 1. To start work with this package, simply add the dependency to your pom.xml: ``` - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://repo1.maven.org/maven2/ - - - com.github.aquality-automation aquality-selenium @@ -46,7 +35,7 @@ browser.waitForPageToLoad(); ```java ElementFactory elementFactory = new ElementFactory(); ITextBox txbSearch = elementFactory.getTextBox(By.id("searchInput"), "Search"); - +browser.waitForPageToLoad(); ``` 5. Call element's methods to perform action with element: diff --git a/src/main/resources/localization/en.json b/src/main/resources/localization/en.json index e2266b8..99c4eb1 100644 --- a/src/main/resources/localization/en.json +++ b/src/main/resources/localization/en.json @@ -63,6 +63,6 @@ "loc.waitnotexists" : "Wait until element does not exist in DOM during %1$s seconds", "loc.no.elements.found.in.state" : "no elements with locator '%1$s' found in state '%2$s' during %3$s seconds", "loc.no.elements.found.by.locator" : "No elements were found by locator '%1$s'", - "loc.elements.were.found.but.not.in.state" : "Elements were found by locator '%1$s'. But %2$s", + "loc.elements.were.found.but.not.in.state" : "Elements were found by locator '%1$s' but not in desired state. %2$s", "loc.elements.found.but.should.not": "No elements should be found by locator '%1$s'" } \ No newline at end of file diff --git a/src/main/resources/localization/ru.json b/src/main/resources/localization/ru.json index bdb5c94..41ad4fe 100644 --- a/src/main/resources/localization/ru.json +++ b/src/main/resources/localization/ru.json @@ -63,6 +63,6 @@ "loc.waitnotexists" : "Ожидаем исчезновения элемента из DOM в течении %1$s", "loc.no.elements.found.in.state" : "не удалось найти элементов по локатору '%1$s' в состоянии '%2$s' на протяжении %3$s секунд", "loc.no.elements.found.by.locator" : "Не удалось найти элементов по локатору '%1$s'", - "loc.elements.were.found.but.not.in.state" : "Удалось найти элементы по локатору '%1$s'. Но %2$s", + "loc.elements.were.found.but.not.in.state" : "Удалось найти элементы по локатору '%1$s',но они не желаемом состоянии. %2$s", "loc.elements.found.but.should.not": "Не должно быть найдено элементов по локатору '%1$s'" } \ No newline at end of file diff --git a/src/test/java/tests/usecases/QuickStartExample.java b/src/test/java/tests/usecases/QuickStartExample.java index c0a73fe..cb572dc 100644 --- a/src/test/java/tests/usecases/QuickStartExample.java +++ b/src/test/java/tests/usecases/QuickStartExample.java @@ -20,6 +20,7 @@ public void test(){ ElementFactory elementFactory = new ElementFactory(); ITextBox txbSearch = elementFactory.getTextBox(By.id("searchInput"), "Search"); txbSearch.type("quality assurance"); + browser.waitForPageToLoad(); browser.quit(); } From 85c4716103b17dfd7ddd89b216c4b33eca3e80f5 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Tue, 27 Aug 2019 19:31:08 +0300 Subject: [PATCH 03/25] fixes of syntax issues updated test of findElements updated QuickStartExample updated readme --- README.md | 1 + src/main/resources/localization/ru.json | 2 +- src/test/java/tests/integration/HiddenElementsTests.java | 4 ++-- src/test/java/tests/usecases/QuickStartExample.java | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c4c9c7d..29bb5a0 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ browser.waitForPageToLoad(); ```java ElementFactory elementFactory = new ElementFactory(); ITextBox txbSearch = elementFactory.getTextBox(By.id("searchInput"), "Search"); +txbSearch.submit(); browser.waitForPageToLoad(); ``` diff --git a/src/main/resources/localization/ru.json b/src/main/resources/localization/ru.json index 41ad4fe..20f07e9 100644 --- a/src/main/resources/localization/ru.json +++ b/src/main/resources/localization/ru.json @@ -63,6 +63,6 @@ "loc.waitnotexists" : "Ожидаем исчезновения элемента из DOM в течении %1$s", "loc.no.elements.found.in.state" : "не удалось найти элементов по локатору '%1$s' в состоянии '%2$s' на протяжении %3$s секунд", "loc.no.elements.found.by.locator" : "Не удалось найти элементов по локатору '%1$s'", - "loc.elements.were.found.but.not.in.state" : "Удалось найти элементы по локатору '%1$s',но они не желаемом состоянии. %2$s", + "loc.elements.were.found.but.not.in.state" : "Удалось найти элементы по локатору '%1$s',но они не в желаемом состоянии. %2$s", "loc.elements.found.but.should.not": "Не должно быть найдено элементов по локатору '%1$s'" } \ No newline at end of file diff --git a/src/test/java/tests/integration/HiddenElementsTests.java b/src/test/java/tests/integration/HiddenElementsTests.java index ecf54f6..67b4939 100644 --- a/src/test/java/tests/integration/HiddenElementsTests.java +++ b/src/test/java/tests/integration/HiddenElementsTests.java @@ -35,8 +35,8 @@ public void testHiddenElementsExist() { } @Test - public void testNotHiddenElementsNotDisplayed() { + public void testFindDisplayedElementsShouldReturnNoElementsIfTheyAreNotDisplayed() { List listElements = new SliderForm().getListElements(ElementState.DISPLAYED, ElementsCount.MORE_THEN_ZERO); - Assert.assertFalse(listElements.isEmpty()); + Assert.assertTrue(listElements.isEmpty()); } } diff --git a/src/test/java/tests/usecases/QuickStartExample.java b/src/test/java/tests/usecases/QuickStartExample.java index cb572dc..55b8319 100644 --- a/src/test/java/tests/usecases/QuickStartExample.java +++ b/src/test/java/tests/usecases/QuickStartExample.java @@ -20,6 +20,7 @@ public void test(){ ElementFactory elementFactory = new ElementFactory(); ITextBox txbSearch = elementFactory.getTextBox(By.id("searchInput"), "Search"); txbSearch.type("quality assurance"); + txbSearch.submit(); browser.waitForPageToLoad(); browser.quit(); From 6f17aab8536ab19144be694533678646e6f59a9d Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 11:37:37 +0300 Subject: [PATCH 04/25] updated chromedriver version in the maven command --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c5fded7..5cfaa83 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,4 +27,4 @@ jobs: - ~/.m2 key: v1-dependencies-{{ checksum "pom.xml" }} - - run: mvn clean test -Dprofile=local \ No newline at end of file + - run: mvn clean test -Dprofile=local -DdriverSettings.chrome.webDriverVersion=76.0.3809.126 \ No newline at end of file From 91d1eaacb8724ed7b907c38d15d2491aecdb9a11 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 11:46:48 +0300 Subject: [PATCH 05/25] updated circleci docker image --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5cfaa83..7aca6c1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/openjdk:8-jdk-stretch-node-browsers + - image: circleci/openjdk:11-jdk-stretch-node-browsers working_directory: ~/repo @@ -27,4 +27,4 @@ jobs: - ~/.m2 key: v1-dependencies-{{ checksum "pom.xml" }} - - run: mvn clean test -Dprofile=local -DdriverSettings.chrome.webDriverVersion=76.0.3809.126 \ No newline at end of file + - run: mvn clean test -Dprofile=local \ No newline at end of file From 3dda66667165ad3061809b3f6945a2be04306fd2 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 12:04:09 +0300 Subject: [PATCH 06/25] added and updated azure pipelines profile --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 23efa78..49d0a7a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,4 +19,4 @@ steps: jdkArchitectureOption: 'x64' publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'clean test' + goals: 'clean test -DdriverSettings.chrome.webDriverVersion=75.0.3770.140' From 3b4b839e40f96989b2ecc02a394e56e260e21535 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 12:12:25 +0300 Subject: [PATCH 07/25] added and updated azure pipelines profile --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49d0a7a..f428aa9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,4 +19,4 @@ steps: jdkArchitectureOption: 'x64' publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'clean test -DdriverSettings.chrome.webDriverVersion=75.0.3770.140' + goals: 'clean test -DdriverSettings.chrome.webDriverVersion=75.0.3770.140 -Dprofile=local' From a6cad93d522300e3b7660748166ceaa2ddd738c6 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 13:50:48 +0300 Subject: [PATCH 08/25] add timer class usage to ElementActionRetrierTest --- .../utils/ElementActionRetrierTests.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java index bf25f4f..633a4bf 100644 --- a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java +++ b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java @@ -4,20 +4,24 @@ import org.openqa.selenium.InvalidArgumentException; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.StaleElementReferenceException; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import utils.Timer; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Date; import java.util.concurrent.atomic.AtomicBoolean; -import static org.testng.Assert.*; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; public class ElementActionRetrierTests { private static final int attemptsCount = Configuration.getInstance().getRetryConfiguration().getNumber(); private static final long pollingInterval = Configuration.getInstance().getRetryConfiguration().getPollingInterval(); + private Timer timer; @DataProvider private Object[][] handledExceptions() { @@ -27,6 +31,11 @@ private Object[][] handledExceptions() { }; } + @BeforeMethod + public void initializeTimer(){ + timer = new Timer(); + } + @Test public void testRetrierShouldWorkOnceIfMethodSucceeded() { Date startTime = new Date(); @@ -36,7 +45,7 @@ public void testRetrierShouldWorkOnceIfMethodSucceeded() { @Test(dataProvider = "handledExceptions") public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException handledException) { - Date startTime = new Date(); + timer.start(); AtomicBoolean isThrowException = new AtomicBoolean(true); ElementActionRetrier.doWithRetry(() -> { if (isThrowException.get()) { @@ -44,8 +53,8 @@ public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException throw handledException; } }); - long duration = new Date().getTime() - startTime.getTime(); - assertTrue(duration >= pollingInterval && duration < 2 * pollingInterval); + double duration = timer.stop(); + assertTrue(duration >= Double.valueOf(pollingInterval)/1000 && duration < 2 * Double.valueOf(pollingInterval)/1000); } @Test(expectedExceptions = InvalidArgumentException.class) @@ -57,7 +66,7 @@ public void testRetrierShouldThrowUnhandledException() { @Test(dataProvider = "handledExceptions") public void testRetrierShouldWorkCorrectTimes(RuntimeException handledException) { - Date startTime = new Date(); + timer.start(); try { ElementActionRetrier.doWithRetry(() -> { throw handledException; @@ -65,8 +74,8 @@ public void testRetrierShouldWorkCorrectTimes(RuntimeException handledException) } catch (RuntimeException e) { assertTrue(handledException.getClass().isInstance(e)); } - long duration = new Date().getTime() - startTime.getTime(); - assertTrue(duration >= pollingInterval * attemptsCount && duration < pollingInterval * (attemptsCount + 1)); + double duration = timer.stop(); + assertTrue(duration >= (Double.valueOf(pollingInterval)/1000) * attemptsCount && duration < (Double.valueOf(pollingInterval)/1000) * (attemptsCount + 1)); } @Test(expectedExceptions = IllegalAccessException.class) From 17de5d8bab9e9a6b0ffe4896414e6563c5693d63 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 14:00:50 +0300 Subject: [PATCH 09/25] refactored download dir test --- src/test/java/tests/integration/BrowserTests.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/test/java/tests/integration/BrowserTests.java b/src/test/java/tests/integration/BrowserTests.java index e21609b..fe385a0 100644 --- a/src/test/java/tests/integration/BrowserTests.java +++ b/src/test/java/tests/integration/BrowserTests.java @@ -16,8 +16,6 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.util.ArrayList; -import java.util.List; import static automationpractice.Constants.URL_AUTOMATIONPRACTICE; import static utils.FileUtil.getResourceFileByName; @@ -204,15 +202,7 @@ public void testShouldBePossibleToSetImplicitWait(){ @Test public void testShouldBePossibleToGetDownloadDir(){ - List listOfDownloadDirs = new ArrayList<>(); - listOfDownloadDirs.add("//home//selenium//downloads"); - listOfDownloadDirs.add("/Users/username/Downloads"); - listOfDownloadDirs.add("target//downloads"); - listOfDownloadDirs.add("/home/circleci/repo/target/downloads"); - - boolean isDirFound = listOfDownloadDirs.stream() - .anyMatch(dir -> getBrowser().getDownloadDirectory().toLowerCase().contains(dir.toLowerCase())); - Assert.assertTrue(isDirFound, "Browser download directory is not correct " + getBrowser().getDownloadDirectory()); + Assert.assertFalse(getBrowser().getDownloadDirectory().isEmpty(), "Browser download directory should not be empty " + getBrowser().getDownloadDirectory()); } private JsonFile getSettings() { From 74c27816d09c07fecbac880ba12ad392f2ed7b25 Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 18:35:12 +0300 Subject: [PATCH 10/25] fix for element retrier test - timer is inside of each test --- .../selenium/utils/ElementActionRetrierTests.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java index 633a4bf..1d4a1d6 100644 --- a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java +++ b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java @@ -4,7 +4,6 @@ import org.openqa.selenium.InvalidArgumentException; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.StaleElementReferenceException; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import utils.Timer; @@ -21,7 +20,7 @@ public class ElementActionRetrierTests { private static final int attemptsCount = Configuration.getInstance().getRetryConfiguration().getNumber(); private static final long pollingInterval = Configuration.getInstance().getRetryConfiguration().getPollingInterval(); - private Timer timer; + @DataProvider private Object[][] handledExceptions() { @@ -31,11 +30,6 @@ private Object[][] handledExceptions() { }; } - @BeforeMethod - public void initializeTimer(){ - timer = new Timer(); - } - @Test public void testRetrierShouldWorkOnceIfMethodSucceeded() { Date startTime = new Date(); @@ -45,6 +39,7 @@ public void testRetrierShouldWorkOnceIfMethodSucceeded() { @Test(dataProvider = "handledExceptions") public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException handledException) { + Timer timer = new Timer(); timer.start(); AtomicBoolean isThrowException = new AtomicBoolean(true); ElementActionRetrier.doWithRetry(() -> { @@ -66,6 +61,7 @@ public void testRetrierShouldThrowUnhandledException() { @Test(dataProvider = "handledExceptions") public void testRetrierShouldWorkCorrectTimes(RuntimeException handledException) { + Timer timer = new Timer(); timer.start(); try { ElementActionRetrier.doWithRetry(() -> { From 925e0b28cd592983888373d8e02f94dbcc5a3eee Mon Sep 17 00:00:00 2001 From: "d.bogatko" Date: Thu, 29 Aug 2019 18:36:47 +0300 Subject: [PATCH 11/25] removed circle ci config --- .circleci/config.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 7aca6c1..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/openjdk:11-jdk-stretch-node-browsers - - working_directory: ~/repo - - environment: - # Customize the JVM maximum heap limit - MAVEN_OPTS: -Xmx3200m - - steps: - - checkout - - # Download and cache dependencies - - restore_cache: - keys: - - v1-dependencies-{{ checksum "pom.xml" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: mvn dependency:go-offline - - - save_cache: - paths: - - ~/.m2 - key: v1-dependencies-{{ checksum "pom.xml" }} - - - run: mvn clean test -Dprofile=local \ No newline at end of file From d32b98d87c6c624b3ebc1031adeb8b9805102562 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 10:07:41 +0300 Subject: [PATCH 12/25] update testRetrierShouldWaitPollingTimeBetweenMethodsCall split assertion to get more informative message in case of failure --- .../utils/ElementActionRetrierTests.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java index 1d4a1d6..a26048b 100644 --- a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java +++ b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java @@ -1,6 +1,7 @@ package aquality.selenium.utils; import aquality.selenium.configuration.Configuration; +import org.apache.commons.lang3.time.StopWatch; import org.openqa.selenium.InvalidArgumentException; import org.openqa.selenium.InvalidElementStateException; import org.openqa.selenium.StaleElementReferenceException; @@ -11,6 +12,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Date; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import static org.testng.Assert.assertEquals; @@ -39,8 +41,8 @@ public void testRetrierShouldWorkOnceIfMethodSucceeded() { @Test(dataProvider = "handledExceptions") public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException handledException) { - Timer timer = new Timer(); - timer.start(); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); AtomicBoolean isThrowException = new AtomicBoolean(true); ElementActionRetrier.doWithRetry(() -> { if (isThrowException.get()) { @@ -48,8 +50,11 @@ public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException throw handledException; } }); - double duration = timer.stop(); - assertTrue(duration >= Double.valueOf(pollingInterval)/1000 && duration < 2 * Double.valueOf(pollingInterval)/1000); + stopWatch.stop(); + + long duration = stopWatch.getTime(TimeUnit.MILLISECONDS); + assertTrue(duration >= pollingInterval, "duration should be more than polling interval"); + assertTrue(duration <= 2 * pollingInterval, "duration should be less than doubled polling interval"); } @Test(expectedExceptions = InvalidArgumentException.class) @@ -71,7 +76,8 @@ public void testRetrierShouldWorkCorrectTimes(RuntimeException handledException) assertTrue(handledException.getClass().isInstance(e)); } double duration = timer.stop(); - assertTrue(duration >= (Double.valueOf(pollingInterval)/1000) * attemptsCount && duration < (Double.valueOf(pollingInterval)/1000) * (attemptsCount + 1)); + double pollingIntervalInSeconds = (double) pollingInterval /1000; + assertTrue(duration >= pollingIntervalInSeconds * attemptsCount && duration < pollingIntervalInSeconds * (attemptsCount + 1)); } @Test(expectedExceptions = IllegalAccessException.class) From e251978fcc335f122b395c38d24a0eb661f4671a Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 10:36:15 +0300 Subject: [PATCH 13/25] extend logging. rework testRetrierShouldWorkCorrectTimes test --- .../utils/ElementActionRetrierTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java index a26048b..6bbc408 100644 --- a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java +++ b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java @@ -1,6 +1,7 @@ package aquality.selenium.utils; import aquality.selenium.configuration.Configuration; +import aquality.selenium.logger.Logger; import org.apache.commons.lang3.time.StopWatch; import org.openqa.selenium.InvalidArgumentException; import org.openqa.selenium.InvalidElementStateException; @@ -14,13 +15,14 @@ import java.util.Date; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; public class ElementActionRetrierTests { - private static final int attemptsCount = Configuration.getInstance().getRetryConfiguration().getNumber(); + private static final int retriesCount = Configuration.getInstance().getRetryConfiguration().getNumber(); private static final long pollingInterval = Configuration.getInstance().getRetryConfiguration().getPollingInterval(); @@ -53,8 +55,8 @@ public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException stopWatch.stop(); long duration = stopWatch.getTime(TimeUnit.MILLISECONDS); - assertTrue(duration >= pollingInterval, "duration should be more than polling interval"); - assertTrue(duration <= 2 * pollingInterval, "duration should be less than doubled polling interval"); + assertTrue(duration >= pollingInterval, "duration should be more than polling interval. actual is " + pollingInterval + " milliseconds"); + assertTrue(duration <= 2 * pollingInterval, "duration should be less than doubled polling interval. actual is " + pollingInterval + " milliseconds"); } @Test(expectedExceptions = InvalidArgumentException.class) @@ -66,18 +68,16 @@ public void testRetrierShouldThrowUnhandledException() { @Test(dataProvider = "handledExceptions") public void testRetrierShouldWorkCorrectTimes(RuntimeException handledException) { - Timer timer = new Timer(); - timer.start(); + AtomicInteger actualAttempts = new AtomicInteger(0); try { ElementActionRetrier.doWithRetry(() -> { + Logger.getInstance().info("current attempt is "+actualAttempts.incrementAndGet()); throw handledException; }); } catch (RuntimeException e) { assertTrue(handledException.getClass().isInstance(e)); } - double duration = timer.stop(); - double pollingIntervalInSeconds = (double) pollingInterval /1000; - assertTrue(duration >= pollingIntervalInSeconds * attemptsCount && duration < pollingIntervalInSeconds * (attemptsCount + 1)); + assertEquals(actualAttempts.get(), retriesCount + 1, "actual attempts count is not match to expected"); } @Test(expectedExceptions = IllegalAccessException.class) From 45febc62e9fab90f57a62c74eb1e3e06ce6178bf Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 10:39:39 +0300 Subject: [PATCH 14/25] fix logged variable --- .../aquality/selenium/utils/ElementActionRetrierTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java index 6bbc408..758055b 100644 --- a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java +++ b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java @@ -55,8 +55,8 @@ public void testRetrierShouldWaitPollingTimeBetweenMethodsCall(RuntimeException stopWatch.stop(); long duration = stopWatch.getTime(TimeUnit.MILLISECONDS); - assertTrue(duration >= pollingInterval, "duration should be more than polling interval. actual is " + pollingInterval + " milliseconds"); - assertTrue(duration <= 2 * pollingInterval, "duration should be less than doubled polling interval. actual is " + pollingInterval + " milliseconds"); + assertTrue(duration >= pollingInterval, "duration should be more than polling interval. actual is " + duration + " milliseconds"); + assertTrue(duration <= 2 * pollingInterval, "duration should be less than doubled polling interval. actual is " + duration + " milliseconds"); } @Test(expectedExceptions = InvalidArgumentException.class) From c1fbb64920d5a98030aaa2daab78a96bd98364e7 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 10:51:54 +0300 Subject: [PATCH 15/25] comment not failed tests --- src/test/resources/TestSuite.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/resources/TestSuite.xml b/src/test/resources/TestSuite.xml index 1704580..1e10e49 100644 --- a/src/test/resources/TestSuite.xml +++ b/src/test/resources/TestSuite.xml @@ -4,16 +4,16 @@ - + - + \ No newline at end of file From 3ff26a7f717b69ee31e0de69dd135d4733f369e6 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 11:28:12 +0300 Subject: [PATCH 16/25] moved retrier to non-threadsafe tests --- src/test/resources/TestSuite.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/resources/TestSuite.xml b/src/test/resources/TestSuite.xml index 1e10e49..b3c6f74 100644 --- a/src/test/resources/TestSuite.xml +++ b/src/test/resources/TestSuite.xml @@ -4,16 +4,15 @@ - - + - + \ No newline at end of file From cdaf457d64a8369adcb0dc0b997d0f3dc84dcfc1 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 11:41:57 +0300 Subject: [PATCH 17/25] increase pageload timeout --- src/test/resources/settings.local.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/settings.local.json b/src/test/resources/settings.local.json index ed81881..e537073 100644 --- a/src/test/resources/settings.local.json +++ b/src/test/resources/settings.local.json @@ -56,7 +56,7 @@ "timeoutImplicit" : 0, "timeoutCondition" : 30, "timeoutScript" : 10, - "timeoutPageLoad" : 15, + "timeoutPageLoad" : 30, "timeoutPollingInterval": 300, "timeoutCommand": 120 }, From c6c4f0a83d71c51ee8529e71a6f3bf9adcc76b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alaksiej=20Miale=C5=A1ka?= Date: Tue, 3 Sep 2019 11:13:55 +0200 Subject: [PATCH 18/25] Update azure-pipelines.yml for Azure Pipelines add ScreenResolutionUtility task --- azure-pipelines.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f428aa9..dbfb903 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,6 +10,9 @@ pool: vmImage: 'windows-latest' steps: +- task: ScreenResolutionUtility@1 + inputs: + displaySettings: 'optimal' - task: Maven@3 inputs: mavenPomFile: 'pom.xml' From d98c9b73b2800f79ec219243d93088618de22671 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 12:38:16 +0300 Subject: [PATCH 19/25] removed duplication from ActionTests. try to set FirefoxDriver to be x32 --- .../forms/ProductListForm.java | 6 +++-- .../java/tests/integration/ActionTests.java | 23 ++++--------------- src/test/resources/settings.local.json | 1 + 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/test/java/automationpractice/forms/ProductListForm.java b/src/test/java/automationpractice/forms/ProductListForm.java index 8d3729c..b7909eb 100644 --- a/src/test/java/automationpractice/forms/ProductListForm.java +++ b/src/test/java/automationpractice/forms/ProductListForm.java @@ -28,7 +28,7 @@ public List getProductContainerLabels(){ return getElementFactory().findElements(By.xpath(XPATH_PRODUCT_CONTAINER), ElementType.LABEL, ElementState.DISPLAYED, ElementsCount.MORE_THEN_ZERO); } - public ILabel getLblFirstProduct(){ + private ILabel getLblFirstProduct(){ return getElementFactory().getLabel(By.xpath(XPATH_PRODUCT.concat("[1]")), "First product"); } @@ -36,7 +36,9 @@ public ILabel getLblLastProduct(){ return getElementFactory().getLabel(By.id("homefeatured"), "home featured").findChildElement(By.xpath("//li".concat("[last()]")), ILabel.class); } - public IButton getBtnLastProductMore(){ + public IButton getBtnLastProductMoreFocused() { + getLblFirstProduct().getMouseActions().moveMouseToElement(); + getLblLastProduct().getMouseActions().moveMouseToElement(); return getLblLastProduct().findChildElement(By.xpath(".//a[contains(@class, 'lnk_view')]"), ElementType.BUTTON); } diff --git a/src/test/java/tests/integration/ActionTests.java b/src/test/java/tests/integration/ActionTests.java index d825db3..28a9ece 100644 --- a/src/test/java/tests/integration/ActionTests.java +++ b/src/test/java/tests/integration/ActionTests.java @@ -43,18 +43,14 @@ public void testScrollIntoView() { @Test public void testMoveMouseToElement() { - ProductListForm productListForm = new ProductListForm(); - productListForm.getLblFirstProduct().getMouseActions().moveMouseToElement(); - productListForm.getLblLastProduct().getMouseActions().moveMouseToElement(); - IButton button = productListForm.getBtnLastProductMore(); + IButton button = new ProductListForm().getBtnLastProductMoreFocused(); Assert.assertTrue(button.getText().contains("More"), "element is not focused after moveMouseToElement()"); } @Test public void testMoveMouseFromElement() { ProductListForm productListForm = new ProductListForm(); - productListForm.getLblLastProduct().getMouseActions().moveMouseToElement(); - IButton button = productListForm.getBtnLastProductMore(); + IButton button = productListForm.getBtnLastProductMoreFocused(); Assert.assertTrue(button.getText().contains("More"), "element is not focused after moveMouseToElement()"); productListForm.getLblLastProduct().getMouseActions().moveMouseFromElement(); Assert.assertFalse(button.state().isDisplayed(), "element is still focused after moveMouseFromElement()"); @@ -62,20 +58,14 @@ public void testMoveMouseFromElement() { @Test public void testGetElementText() { - ProductListForm productListForm = new ProductListForm(); - productListForm.getLblFirstProduct().getMouseActions().moveMouseToElement(); - productListForm.getLblLastProduct().getMouseActions().moveMouseToElement(); - IButton button = productListForm.getBtnLastProductMore(); + IButton button = new ProductListForm().getBtnLastProductMoreFocused(); Assert.assertEquals(button.getText().trim(), button.getJsActions().getElementText().trim(), "element text got via JsActions is not match to expected"); } @Test public void testSetFocus() { - ProductListForm productListForm = new ProductListForm(); - productListForm.getLblFirstProduct().getMouseActions().moveMouseToElement(); - productListForm.getLblLastProduct().getMouseActions().moveMouseToElement(); - productListForm.getBtnLastProductMore().getJsActions().clickAndWait(); + new ProductListForm().getBtnLastProductMoreFocused().getJsActions().clickAndWait(); ITextBox txbQuantity = new ProductForm().getTxbQuantity(); txbQuantity.getJsActions().setFocus(); @@ -87,10 +77,7 @@ public void testSetFocus() { @Test public void testSetValue() { - ProductListForm productListForm = new ProductListForm(); - productListForm.getLblFirstProduct().getMouseActions().moveMouseToElement(); - productListForm.getLblLastProduct().getMouseActions().moveMouseToElement(); - productListForm.getBtnLastProductMore().getJsActions().clickAndWait(); + new ProductListForm().getBtnLastProductMoreFocused().getJsActions().clickAndWait(); ProductForm productForm = new ProductForm(); ITextBox txbQuantity = productForm.getTxbQuantity(); diff --git a/src/test/resources/settings.local.json b/src/test/resources/settings.local.json index e537073..857f583 100644 --- a/src/test/resources/settings.local.json +++ b/src/test/resources/settings.local.json @@ -22,6 +22,7 @@ }, "firefox": { "webDriverVersion": "latest", + "systemArchitecture": "X32", "capabilities": { "enableVNC": true }, From 5eeb09d79f86feb9d94a0dfe14afe5c3a041786f Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 13:34:05 +0300 Subject: [PATCH 20/25] fix ElementFactory and some tests --- pom.xml | 6 +++--- .../java/aquality/selenium/elements/ElementFactory.java | 9 ++++----- src/test/java/tests/integration/ElementStateTests.java | 2 +- src/test/java/tests/integration/HiddenElementsTests.java | 2 +- src/test/java/tests/usecases/BrowserFactoryTests.java | 3 ++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 848b41e..785fa74 100644 --- a/pom.xml +++ b/pom.xml @@ -166,9 +166,9 @@ methods 10 false - - **/*Test*.java - + + src/test/resources/TestSuite.xml + diff --git a/src/main/java/aquality/selenium/elements/ElementFactory.java b/src/main/java/aquality/selenium/elements/ElementFactory.java index 6d60f52..776ce17 100644 --- a/src/main/java/aquality/selenium/elements/ElementFactory.java +++ b/src/main/java/aquality/selenium/elements/ElementFactory.java @@ -102,16 +102,15 @@ private List findElementsCore(By locator, IElementSuppl List elements = new ArrayList<>(); switch (count) { case ZERO: - ConditionalWait.waitFor(driver -> driver.findElements(locator).isEmpty(), + ConditionalWait.waitFor(driver -> driver.findElements(locator).stream() + .noneMatch(webElement -> state == ElementState.EXISTS_IN_ANY_STATE || webElement.isDisplayed()), String.format(LocalizationManager.getInstance().getValue("loc.elements.found.but.should.not"), locator.toString())); break; case MORE_THEN_ZERO: ConditionalWait.waitFor(driver -> !driver.findElements(locator).isEmpty(), - String.format(LocalizationManager.getInstance().getValue("loc.no.elements.found.in.state"), - locator.toString(), - state.toString(), - getTimeoutConfig())); + String.format(LocalizationManager.getInstance().getValue("loc.no.elements.found.by.locator"), + locator.toString())); break; default: throw new IllegalArgumentException("No such expected value:".concat(count.toString())); diff --git a/src/test/java/tests/integration/ElementStateTests.java b/src/test/java/tests/integration/ElementStateTests.java index fe3f744..8952120 100644 --- a/src/test/java/tests/integration/ElementStateTests.java +++ b/src/test/java/tests/integration/ElementStateTests.java @@ -16,7 +16,7 @@ public class ElementStateTests extends BaseTest { - private final double operationTime = 2; + private final double operationTime = 5; private final long customWaitTime = 2L; private final ElementFactory elementFactory = new ElementFactory(); private final ILabel lblNotExists = elementFactory.getLabel(By.xpath("//div[@class='not exist element']"), "not exist element"); diff --git a/src/test/java/tests/integration/HiddenElementsTests.java b/src/test/java/tests/integration/HiddenElementsTests.java index 67b4939..00fe5a3 100644 --- a/src/test/java/tests/integration/HiddenElementsTests.java +++ b/src/test/java/tests/integration/HiddenElementsTests.java @@ -36,7 +36,7 @@ public void testHiddenElementsExist() { @Test public void testFindDisplayedElementsShouldReturnNoElementsIfTheyAreNotDisplayed() { - List listElements = new SliderForm().getListElements(ElementState.DISPLAYED, ElementsCount.MORE_THEN_ZERO); + List listElements = new SliderForm().getListElements(ElementState.DISPLAYED, ElementsCount.ZERO); Assert.assertTrue(listElements.isEmpty()); } } diff --git a/src/test/java/tests/usecases/BrowserFactoryTests.java b/src/test/java/tests/usecases/BrowserFactoryTests.java index 849dd47..3735f42 100644 --- a/src/test/java/tests/usecases/BrowserFactoryTests.java +++ b/src/test/java/tests/usecases/BrowserFactoryTests.java @@ -37,7 +37,8 @@ public class BrowserFactoryTests { private final JsonFile jsonProfile; public BrowserFactoryTests() { - this.jsonProfile = new JsonFile("settings.json"); + String settingsProfile = System.getProperty("profile") == null ? "settings.json" : "settings." + System.getProperty("profile") + ".json"; + this.jsonProfile = new JsonFile(settingsProfile); } @Test From 4de590589b828a2da27927486c11a2f26b41fa88 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 13:53:37 +0300 Subject: [PATCH 21/25] set parallel to false in suite file --- src/test/resources/TestSuite.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/TestSuite.xml b/src/test/resources/TestSuite.xml index b3c6f74..2548f31 100644 --- a/src/test/resources/TestSuite.xml +++ b/src/test/resources/TestSuite.xml @@ -22,7 +22,7 @@ - + From cf22deb076a63dae242b6f25af3bdad826caf7ed Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 13:58:35 +0300 Subject: [PATCH 22/25] stabilize ActionTests related to focus on last product tile --- .../java/automationpractice/forms/ProductListForm.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/automationpractice/forms/ProductListForm.java b/src/test/java/automationpractice/forms/ProductListForm.java index b7909eb..1b8bc68 100644 --- a/src/test/java/automationpractice/forms/ProductListForm.java +++ b/src/test/java/automationpractice/forms/ProductListForm.java @@ -39,7 +39,12 @@ public ILabel getLblLastProduct(){ public IButton getBtnLastProductMoreFocused() { getLblFirstProduct().getMouseActions().moveMouseToElement(); getLblLastProduct().getMouseActions().moveMouseToElement(); - return getLblLastProduct().findChildElement(By.xpath(".//a[contains(@class, 'lnk_view')]"), ElementType.BUTTON); + IButton btnLastProductMore = getLblLastProduct().findChildElement(By.xpath(".//a[contains(@class, 'lnk_view')]"), ElementType.BUTTON); + if(!btnLastProductMore.state().isDisplayed()) { + getLblLastProduct().getMouseActions().moveMouseFromElement(); + getLblLastProduct().getMouseActions().moveMouseToElement(); + } + return btnLastProductMore; } public void addToCardRandomProduct(){ From 5eee0a21e4a51781255c73d34242626525b12d58 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 14:11:01 +0300 Subject: [PATCH 23/25] try to remove some forks settings from the pom file --- pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index 785fa74..b7ae786 100644 --- a/pom.xml +++ b/pom.xml @@ -163,8 +163,6 @@ 2.20 ${surefireArgLine} -Dfile.encoding=UTF-8 - methods - 10 false src/test/resources/TestSuite.xml From 50359a1ee9c0114e612ce13add1fa36839fd84ce Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 14:26:44 +0300 Subject: [PATCH 24/25] try to set parallel to none for some tests --- src/test/resources/TestSuite.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/TestSuite.xml b/src/test/resources/TestSuite.xml index 2548f31..213e913 100644 --- a/src/test/resources/TestSuite.xml +++ b/src/test/resources/TestSuite.xml @@ -22,7 +22,7 @@ - + From faa8cb96504d93b39ae8280400f1ba0c6b403d63 Mon Sep 17 00:00:00 2001 From: "Meleshko, Aleksey2" Date: Tue, 3 Sep 2019 14:47:42 +0300 Subject: [PATCH 25/25] fix spaces in test --- .../java/aquality/selenium/utils/ElementActionRetrierTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java index 758055b..1a79e3d 100644 --- a/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java +++ b/src/test/java/aquality/selenium/utils/ElementActionRetrierTests.java @@ -71,7 +71,7 @@ public void testRetrierShouldWorkCorrectTimes(RuntimeException handledException) AtomicInteger actualAttempts = new AtomicInteger(0); try { ElementActionRetrier.doWithRetry(() -> { - Logger.getInstance().info("current attempt is "+actualAttempts.incrementAndGet()); + Logger.getInstance().info("current attempt is " + actualAttempts.incrementAndGet()); throw handledException; }); } catch (RuntimeException e) {