Skip to content

Commit

Permalink
Upgrade to Java 17 / upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
grossopa committed Dec 1, 2024
1 parent 52f2ace commit 44b4fde
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class HtmlSelect extends DefaultWebComponent implements ISelect {
* Constructs an instance with element and driver.
*
* @param element the web element to wrap with, should be with tag select.
* @param driver the current web driver
* @param driver the current web driver
*/
public HtmlSelect(WebElement element, ComponentWebDriver driver) {
super(element, driver);
Expand Down Expand Up @@ -79,6 +79,11 @@ public void selectByVisibleText(String text) {
selectComponent.selectByVisibleText(text);
}

@Override
public void selectByContainsVisibleText(String text) {
selectComponent.selectByContainsVisibleText(text);
}

@Override
public void selectByIndex(int index) {
selectComponent.selectByIndex(index);
Expand Down Expand Up @@ -109,18 +114,22 @@ public void deselectByVisibleText(String text) {
selectComponent.deselectByVisibleText(text);
}

@Override
public void deSelectByContainsVisibleText(String text) {
selectComponent.deSelectByContainsVisibleText(text);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof HtmlSelect)) {
if (!(o instanceof HtmlSelect that)) {
return false;
}
if (!super.equals(o)) {
return false;
}
HtmlSelect that = (HtmlSelect) o;
return element.equals(that.element);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public String getIsDisabledCss() {
@Override
public boolean isDisabled(WebComponent component) {
return ComponentConfig.super.isDisabled(component) || "true".equalsIgnoreCase(
component.getAttribute("aria-disabled"));
component.getDomAttribute("aria-disabled"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public class MatAutocomplete extends AbstractMatComponent implements Select, Del
* Constructs an instance with the delegated element and root driver
*
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param driver the root driver
* @param config the Material UI Angular configuration
*/
public MatAutocomplete(WebElement element, ComponentWebDriver driver, MatConfig config) {
this(element, driver, config, null, null, null, null);
Expand All @@ -111,44 +111,44 @@ public boolean validate() {
/**
* Constructs an instance with the delegated element and root driver
*
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param overlayFinder optional, the overlay finder for locating the overlay container
*/
public MatAutocomplete(WebElement element, ComponentWebDriver driver, MatConfig config,
@Nullable MatOverlayFinder overlayFinder) {
@Nullable MatOverlayFinder overlayFinder) {
this(element, driver, config, overlayFinder, null, null, null);
}

/**
* Constructs an instance with the delegated element and root driver
*
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param overlayFinder optional, the overlay finder for locating the overlay container
* @param optionLocator optional, the option locator for locating the options within the overlay container
*/
public MatAutocomplete(WebElement element, ComponentWebDriver driver, MatConfig config,
@Nullable MatOverlayFinder overlayFinder, @Nullable By optionLocator) {
@Nullable MatOverlayFinder overlayFinder, @Nullable By optionLocator) {
this(element, driver, config, overlayFinder, optionLocator, null, null);
}

/**
* Constructs an instance with the delegated element and root driver
*
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param overlayFinder optional, the overlay finder for locating the overlay container
* @param optionLocator optional, the option locator for locating the options within the overlay container
* @param openOptionsAction optional, the action to open the option locator
* @param element the delegated element
* @param driver the root driver
* @param config the Material UI Angular configuration
* @param overlayFinder optional, the overlay finder for locating the overlay container
* @param optionLocator optional, the option locator for locating the options within the overlay container
* @param openOptionsAction optional, the action to open the option locator
* @param closeOptionsAction optional, the action to close the option locator
*/
public MatAutocomplete(WebElement element, ComponentWebDriver driver, MatConfig config,
@Nullable MatOverlayFinder overlayFinder, @Nullable By optionLocator,
@Nullable OpenOptionsAction openOptionsAction, @Nullable CloseOptionsAction closeOptionsAction) {
@Nullable MatOverlayFinder overlayFinder, @Nullable By optionLocator,
@Nullable OpenOptionsAction openOptionsAction, @Nullable CloseOptionsAction closeOptionsAction) {
super(element, driver, config);
this.overlayFinder = defaultIfNull(overlayFinder, new MatOverlayFinder(driver, config));
this.optionLocator = defaultIfNull(optionLocator, tagName(config.getTagPrefix() + "option"));
Expand Down Expand Up @@ -295,6 +295,22 @@ public void selectByVisibleText(String text) {
selectByVisibleText(text, 0L);
}

@Override
public void selectByContainsVisibleText(String text) {
this.selectByContainsVisibleText(text, 0L);
}

@Override
public void selectByContainsVisibleText(String text, Long delayInMillis) {
List<WebComponent> options = getOptions2(delayInMillis);
for (WebComponent option : options) {
if (StringUtils.contains(text, option.getText())) {
option.click();
return;
}
}
}

@Override
public void selectByIndex(int i) {
selectByIndex(i, 0L);
Expand Down Expand Up @@ -325,6 +341,16 @@ public void deselectByVisibleText(String visibleText) {
deselectByVisibleText(visibleText, 0L);
}

@Override
public void deSelectByContainsVisibleText(String text) {
this.deSelectByContainsVisibleText(text, 0L);
}

@Override
public void deSelectByContainsVisibleText(String text, long delayInMillis) {
SeleniumUtils.cleanText(this.getInput());
}

protected Optional<WebComponent> tryToFindAutocompletePanel() {
MatOverlayContainer container = overlayFinder.findTopVisibleContainer();
if (container != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,21 @@ public void selectByVisibleText(String text) {
selectByVisibleText(text, 0L);
}

@Override
public void selectByContainsVisibleText(String text) {
this.selectByVisibleText(text, 0L);
}

@Override
public void selectByVisibleText(String text, Long delayInMillis) {
doFilterAndAction(getOptions2(delayInMillis),
option -> !config.isSelected(option) && StringUtils.equals(text, option.getText()));
option -> !config.isSelected(option) && StringUtils.equals(option.getText(), text));
}

@Override
public void selectByContainsVisibleText(String text, Long delayInMillis) {
doFilterAndAction(getOptions2(delayInMillis),
option -> !config.isSelected(option) && StringUtils.contains(option.getText(), text));
}

@Override
Expand All @@ -225,7 +236,7 @@ public void selectByValue(String value) {
@Override
public void selectByValue(String value, Long delayInMillis) {
doFilterAndAction(getOptions2(delayInMillis), option -> !config.isSelected(option) && StringUtils.equals(value,
option.getAttribute(selectConfig.getOptionValueAttribute())));
option.getDomAttribute(selectConfig.getOptionValueAttribute())));
}

@Override
Expand All @@ -247,7 +258,7 @@ public void deselectByValue(String value) {
@Override
public void deselectByValue(String value, Long delayInMillis) {
doFilterAndAction(getOptions2(delayInMillis), option -> config.isSelected(option) && StringUtils.equals(value,
option.getAttribute(selectConfig.getOptionValueAttribute())));
option.getDomAttribute(selectConfig.getOptionValueAttribute())));
}

@Override
Expand All @@ -268,10 +279,21 @@ public void deselectByVisibleText(String text) {
deselectByVisibleText(text, 0L);
}

@Override
public void deSelectByContainsVisibleText(String text) {
this.deSelectByContainsVisibleText(text, 0L);
}

@Override
public void deselectByVisibleText(String text, Long delayInMillis) {
doFilterAndAction(getOptions2(delayInMillis),
option -> config.isSelected(option) && StringUtils.equals(text, option.getText()));
option -> config.isSelected(option) && StringUtils.equals(option.getText(), text));
}

@Override
public void deSelectByContainsVisibleText(String text, long delayInMillis) {
doFilterAndAction(getOptions2(delayInMillis),
option -> config.isSelected(option) && StringUtils.contains(option.getText(), text));
}

private void doFilterAndAction(List<WebComponent> options, Predicate<WebComponent> isTrue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public boolean validate() {
* @return the orientation of current thumb. possible values are "horizontal" and "vertical".
*/
public String getOrientation() {
return element.getAttribute("aria-orientation");
return element.getDomAttribute("aria-orientation");
}

/**
Expand All @@ -89,7 +89,7 @@ public String getOrientation() {
* @return the value text
*/
public String getValueText() {
return element.getAttribute("aria-valuetext");
return element.getDomAttribute("aria-valuetext");
}

/**
Expand All @@ -98,7 +98,7 @@ public String getValueText() {
* @return the raw min value.
*/
public String getMaxValue() {
return element.getAttribute("aria-valuemax");
return element.getDomAttribute("aria-valuemax");
}

/**
Expand All @@ -107,7 +107,7 @@ public String getMaxValue() {
* @return the raw min value.
*/
public String getMinValue() {
return element.getAttribute("aria-valuemin");
return element.getDomAttribute("aria-valuemin");
}

/**
Expand All @@ -116,7 +116,7 @@ public String getMinValue() {
* @return the raw value.
*/
public String getValue() {
return element.getAttribute("aria-valuenow");
return element.getDomAttribute("aria-valuenow");
}

/**
Expand Down
Loading

0 comments on commit 44b4fde

Please sign in to comment.