Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use Selenium 4.24.0 #146

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@
<dependency>
<groupId>com.github.aquality-automation</groupId>
<artifactId>aquality-selenium-core</artifactId>
<version>4.0.4</version>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
<version>3.17.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/aquality/selenium/elements/TextBox.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package aquality.selenium.elements;

import aquality.selenium.core.elements.ElementState;
import aquality.selenium.core.utilities.IElementActionRetrier;
import aquality.selenium.elements.interfaces.ITextBox;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptException;
import org.openqa.selenium.Keys;

import java.util.ArrayList;

/**
* The class that describes an input field
*/
Expand Down Expand Up @@ -37,6 +41,15 @@ public void clearAndType(final String value) {
clearAndType(value, false);
}

@Override
public void clear() {
logElementAction(LOG_CLEARING);
getJsActions().highlightElement();
doWithRetry(() -> {
getElement().clear();
});
}

@Override
public void clearAndTypeSecret(final String value) {
clearAndType(value, true);
Expand All @@ -62,7 +75,16 @@ public void unfocus() {
doWithRetry(() -> getElement().sendKeys(Keys.TAB));
}

private void type(final String value, final boolean maskValueInLog) {
@Override
protected void doWithRetry(Runnable action) {
IElementActionRetrier retrier = getElementActionRetrier();
ArrayList<Class<? extends Throwable>> handledExceptions = new ArrayList<>(retrier.getHandledExceptions());
handledExceptions.add(JavascriptException.class);
retrier.doWithRetry(action, handledExceptions);
}

private void type(final String value, final boolean maskValueInLog)
{
logElementAction(LOG_TYPING, maskValueInLog ? logMaskedValue : value);
getJsActions().highlightElement();
doWithRetry(() -> getElement().sendKeys(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public interface ITextBox extends IElement {
*/
void typeSecret(String value);

/**
* Clears element text.
*/
void clear();

/**
* Clears input and enters text in the box, inputted value isn't logging
*
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/tests/integration/ActionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import aquality.selenium.elements.interfaces.ILabel;
import aquality.selenium.elements.interfaces.ILink;
import aquality.selenium.elements.interfaces.ITextBox;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.Keys;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -131,6 +132,22 @@ public void testSetFocus() {
Assert.assertEquals(textBox.getValue(), expectedText, "One character should be removed from " + expectedText);
}

@Test
public void testClear() {
FormAuthenticationForm form = new FormAuthenticationForm();
getBrowser().goTo(form.getUrl());
ITextBox textBox = form.getTxbUsername();
textBox.clear();
Assert.assertTrue(StringUtils.isEmpty(textBox.getValue()), "Clear should work when was initially empty");
textBox.type("anything");
textBox.clear();
Assert.assertTrue(StringUtils.isEmpty(textBox.getValue()), "Clear should work when was not empty");
textBox.type("anything");
textBox.clear();
textBox.clear();
Assert.assertTrue(StringUtils.isEmpty(textBox.getValue()), "Clear should work called twice");
}

@Test
public void testSetValue() {
final String expectedValue = "2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import aquality.selenium.browser.AqualityServices;
import aquality.selenium.browser.devtools.EmulationHandling;
import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.devtools.v127.emulation.Emulation;
import org.openqa.selenium.devtools.v127.emulation.model.DisplayFeature;
import org.openqa.selenium.devtools.v128.emulation.Emulation;
import org.openqa.selenium.devtools.v128.emulation.model.DisplayFeature;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import aquality.selenium.browser.AqualityServices;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.devtools.v127.network.model.ConnectionType;
import org.openqa.selenium.devtools.v128.network.model.ConnectionType;
import org.testng.Assert;
import org.testng.annotations.Test;
import tests.BaseTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import manytools.BrowserLanguageForm;
import manytools.UserAgentForm;
import org.openqa.selenium.devtools.idealized.Network;
import org.openqa.selenium.devtools.v127.emulation.Emulation;
import org.openqa.selenium.devtools.v128.emulation.Emulation;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand Down
Loading