From aa6e2baeafb0ce10273019017a0ba2550ac204c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alaksiej=20Miale=C5=A1ka?= Date: Fri, 23 Feb 2024 21:04:35 +0100 Subject: [PATCH] Process element highlight correctly (#137) fixes #128 --- src/main/java/aquality/selenium/elements/Element.java | 6 +++--- .../java/aquality/selenium/elements/actions/JsActions.java | 3 ++- src/test/java/tests/usecases/BrowserConcurrencyTests.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/aquality/selenium/elements/Element.java b/src/main/java/aquality/selenium/elements/Element.java index 4a69b5f..e0524bc 100644 --- a/src/main/java/aquality/selenium/elements/Element.java +++ b/src/main/java/aquality/selenium/elements/Element.java @@ -131,7 +131,7 @@ public String getText() { @Override public String getText(HighlightState highlightState) { logElementAction("loc.get.text"); - getJsActions().highlightElement(); + getJsActions().highlightElement(highlightState); String value = doWithRetry(() -> getElement().getText()); logElementAction("loc.text.value", value); return value; @@ -147,7 +147,7 @@ public IElementStateProvider state() { @Override public String getAttribute(final String attr, HighlightState highlightState) { logElementAction("loc.el.getattr", attr); - getJsActions().highlightElement(); + getJsActions().highlightElement(highlightState); String value = doWithRetry(() -> getElement().getAttribute(attr)); logElementAction("loc.el.attr.value", attr, value); return value; @@ -156,7 +156,7 @@ public String getAttribute(final String attr, HighlightState highlightState) { @Override public String getCssValue(final String propertyName, HighlightState highlightState) { logElementAction("loc.el.cssvalue", propertyName); - getJsActions().highlightElement(); + getJsActions().highlightElement(highlightState); String value = doWithRetry(() -> getElement().getCssValue(propertyName)); logElementAction("loc.el.attr.value", propertyName, value); return value; diff --git a/src/main/java/aquality/selenium/elements/actions/JsActions.java b/src/main/java/aquality/selenium/elements/actions/JsActions.java index f040415..286a043 100644 --- a/src/main/java/aquality/selenium/elements/actions/JsActions.java +++ b/src/main/java/aquality/selenium/elements/actions/JsActions.java @@ -71,7 +71,8 @@ public void highlightElement() { * Highlights the element. */ public void highlightElement(HighlightState highlightState) { - if (AqualityServices.getBrowserProfile().isElementHighlightEnabled() || highlightState.equals(HighlightState.HIGHLIGHT)) { + if ((AqualityServices.getBrowserProfile().isElementHighlightEnabled() && !highlightState.equals(HighlightState.NOT_HIGHLIGHT)) + || highlightState.equals(HighlightState.HIGHLIGHT)) { executeScript(JavaScript.BORDER_ELEMENT); } } diff --git a/src/test/java/tests/usecases/BrowserConcurrencyTests.java b/src/test/java/tests/usecases/BrowserConcurrencyTests.java index 303b082..0ab4b8e 100644 --- a/src/test/java/tests/usecases/BrowserConcurrencyTests.java +++ b/src/test/java/tests/usecases/BrowserConcurrencyTests.java @@ -40,7 +40,7 @@ public void testShouldBePossibleToUseParallelStreams(){ textBoxes.parallelStream().forEach(lbl -> { // set the same instance of browser for all threads AqualityServices.setBrowser(browser); - String text = lbl.getText(HighlightState.HIGHLIGHT); + String text = lbl.getText(HighlightState.NOT_HIGHLIGHT); // processing results of work trough web driver (getting text) String updatedText = text + "_updated"; texts.add(text);