Skip to content

Commit

Permalink
Merge pull request #22 from grossopa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
grossopa authored Dec 28, 2024
2 parents aaeff61 + b83d8c6 commit ae7a6c6
Show file tree
Hide file tree
Showing 185 changed files with 1,202 additions and 695 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
# - name: Build and analyze
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
52 changes: 52 additions & 0 deletions hamster-playwright/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright © 2023 the original author or authors.
~
~ Licensed under the The MIT License (MIT) (the "License");
~ You may obtain a copy of the License at
~
~ https://mit-license.org/
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
~ and associated documentation files (the “Software”), to deal in the Software without
~ restriction, including without limitation the rights to use, copy, modify, merge, publish,
~ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
~ Software is furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all copies or
~ substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
~ BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
~ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
~ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
~ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.grossopa</groupId>
<artifactId>hamster-selenium-parent</artifactId>
<version>1.12.0-SNAPSHOT</version>
</parent>

<artifactId>hamster-playwright</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.31.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,34 @@ void getComponentName() {
@Test
void validate() {
when(element.getTagName()).thenReturn("button");
when(element.getAttribute("class")).thenReturn("sss-btn sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-btn sss-btn-primary");
assertTrue(testSubject.validate());
}

@Test
void validateNegative1() {
when(element.getTagName()).thenReturn("label");
when(element.getAttribute("class")).thenReturn("sss-btn sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-btn sss-btn-primary");
assertFalse(testSubject.validate());
}

@Test
void validateNegative2() {
when(element.getTagName()).thenReturn("button");
when(element.getAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
assertFalse(testSubject.validate());
}

@Test
void isLoadingTrue() {
when(element.getTagName()).thenReturn("button");
when(element.getAttribute("class")).thenReturn("sss-btn sss-btn-loading");
when(element.getDomAttribute("class")).thenReturn("sss-btn sss-btn-loading");
assertTrue(testSubject.isLoading());
}

@Test
void isLoadingFalse() {
when(element.getAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
assertFalse(testSubject.isLoading());
}
}
Original file line number Diff line number Diff line change
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,6 +114,11 @@ 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @author Jack Yin
* @since 1.0
*/
@SuppressWarnings("deprecation")
class HtmlSelectTest {

HtmlSelect testSubject;
Expand All @@ -53,8 +54,10 @@ class HtmlSelectTest {

private WebElement createOption(String value, String label, Integer index, boolean selected) {
WebElement element = mock(WebElement.class);
when(element.getDomAttribute("value")).thenReturn(value);
when(element.getAttribute("value")).thenReturn(value);
when(element.getText()).thenReturn(label);
when(element.getDomAttribute("index")).thenReturn(String.valueOf(index));
when(element.getAttribute("index")).thenReturn(String.valueOf(index));
when(element.isSelected()).thenReturn(selected);
when(element.isEnabled()).thenReturn(true);
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 @@ -230,6 +230,17 @@ public void selectByVisibleText(String text, Long delayInMillis) {
}
}

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

@Override
public void selectByIndex(int index, Long delayInMillis) {
getOptions2(delayInMillis).get(index).click();
Expand Down Expand Up @@ -260,6 +271,11 @@ public void deselectByVisibleText(String text, Long delayInMillis) {
SeleniumUtils.cleanText(this.getInput());
}

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

@Override
public List<WebComponent> getOptions2() {
return getOptions2(0L);
Expand Down Expand Up @@ -295,6 +311,11 @@ public void selectByVisibleText(String text) {
selectByVisibleText(text, 0L);
}

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

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

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

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 @@ -70,7 +70,7 @@ public boolean validate() {

@Override
public boolean isEnabled() {
return element.getAttribute("disabled") == null;
return element.getDomAttribute("disabled") == null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public boolean validate() {
* @return the column count
*/
public int getCols() {
return Integer.parseInt(element.getAttribute("cols"));
return Integer.parseInt(element.getDomAttribute("cols"));
}

public List<MatGridTile> getGridTiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public boolean validate() {
* @return the row span
*/
public int getRowSpan() {
return Integer.parseInt(this.getAttribute("rowspan"));
return Integer.parseInt(this.getDomAttribute("rowspan"));
}

/**
Expand All @@ -78,6 +78,6 @@ public int getRowSpan() {
* @return the row span
*/
public int getColSpan() {
return Integer.parseInt(this.getAttribute("colspan"));
return Integer.parseInt(this.getDomAttribute("colspan"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public boolean validate() {
* @return the min value of the progress bar
*/
public String getMinValue() {
return this.getAttribute("aria-valuemin");
return this.getDomAttribute("aria-valuemin");
}

/**
Expand All @@ -81,7 +81,7 @@ public String getMinValue() {
* @return the max value of the progress bar
*/
public String getMaxValue() {
return this.getAttribute("aria-valuemax");
return this.getDomAttribute("aria-valuemax");
}

/**
Expand All @@ -90,7 +90,7 @@ public String getMaxValue() {
* @return the current of the progress bar
*/
public String getValue() {
return this.getAttribute("aria-valuenow");
return this.getDomAttribute("aria-valuenow");
}

/**
Expand All @@ -99,7 +99,7 @@ public String getValue() {
* @return the current mode
*/
public Mode getMode() {
return Mode.valueOf(upperCase(this.getAttribute("mode")));
return Mode.valueOf(upperCase(this.getDomAttribute("mode")));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean validate() {
*/
@Override
public String getValue() {
return getAttribute("aria-valuenow");
return getDomAttribute("aria-valuenow");
}

/**
Expand Down Expand Up @@ -145,7 +145,7 @@ public Double getValueDouble() {
*/
@Override
public String getMinValue() {
return getAttribute("aria-valuemin");
return getDomAttribute("aria-valuemin");
}

/**
Expand Down Expand Up @@ -197,7 +197,7 @@ public Double getMinValueDouble() {
*/
@Override
public String getMaxValue() {
return getAttribute("aria-valuemax");
return getDomAttribute("aria-valuemax");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public boolean validate() {

@Override
public boolean isSelected() {
return "true".equalsIgnoreCase(this.getAttribute("aria-selected"));
return "true".equalsIgnoreCase(this.getDomAttribute("aria-selected"));
}

@Override
public boolean isEnabled() {
return !"true".equalsIgnoreCase(this.getAttribute("aria-disabled"));
return !"true".equalsIgnoreCase(this.getDomAttribute("aria-disabled"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void isDisabled2() {
WebElement element = mock(WebElement.class);
when(component.getWrappedElement()).thenReturn(element);
when(element.isEnabled()).thenReturn(true);
when(component.getAttribute("class")).thenReturn("mat-disabled");
when(component.getDomAttribute("class")).thenReturn("mat-disabled");
assertTrue(testSubject.isDisabled(component));
}

Expand All @@ -155,8 +155,8 @@ void isDisabled3() {
WebElement element = mock(WebElement.class);
when(component.getWrappedElement()).thenReturn(element);
when(element.isEnabled()).thenReturn(true);
when(component.getAttribute("class")).thenReturn("");
when(component.getAttribute("aria-disabled")).thenReturn("true");
when(component.getDomAttribute("class")).thenReturn("");
when(component.getDomAttribute("aria-disabled")).thenReturn("true");
assertTrue(testSubject.isDisabled(component));
}

Expand All @@ -166,7 +166,7 @@ void isDisabled4() {
WebElement element = mock(WebElement.class);
when(component.getWrappedElement()).thenReturn(element);
when(element.isEnabled()).thenReturn(true);
when(component.getAttribute("class")).thenReturn("");
when(component.getDomAttribute("class")).thenReturn("");
assertFalse(testSubject.isDisabled(component));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void setUp() {

@Test
void validate() {
when(element.getAttribute("class")).thenReturn("mat-accordion");
when(element.getDomAttribute("class")).thenReturn("mat-accordion");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(element.getAttribute("class")).thenReturn("mat-accordion-333");
when(element.getDomAttribute("class")).thenReturn("mat-accordion-333");
assertFalse(testSubject.validate());
}

Expand Down
Loading

0 comments on commit ae7a6c6

Please sign in to comment.