Skip to content

Commit

Permalink
Merge pull request #70 from sukgu/dev
Browse files Browse the repository at this point in the history
Shadow 0.1.5 for Selenium 4
  • Loading branch information
sukgu committed Dec 27, 2023
2 parents aa2052b + d88ed1a commit 3376e82
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 41 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ You can use this plugin by adding jar file or by including maven dependency in y
`public void highlight(WebElement element, String color, Integer timeInMiliSeconds)` : highlight method.

`public void highlight(WebElement element)` : highlight method highlight in red color.


### What's New
##### We support now Selenium version 4 with release of Shadow version 0.1.5
##### Java 11 and Selenium 4.16.1 to be used with Shadow 0.1.5

###### How to use this plugin:
You will have to dependency in your project.

Expand All @@ -91,17 +95,17 @@ You can use this plugin by adding jar file or by including maven dependency in y
<dependency>
<groupId>io.github.sukgu</groupId>
<artifactId>automation</artifactId>
<version>0.1.4.1</version>
<version>0.1.5</version>
</dependency>
```

**Gradle**
```
implementation 'io.github.sukgu:automation:0.1.4.1'
implementation 'io.github.sukgu:automation:0.1.5'
```


You can download the jar file from repository http://central.maven.org/maven2/io/github/sukgu/automation/0.1.4.1/automation-0.1.4.1.jar
You can download the jar file from repository http://central.maven.org/maven2/io/github/sukgu/automation/0.1.5/automation-0.1.5.jar

## Selector:
###### Examples:
Expand Down
2 changes: 1 addition & 1 deletion catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<archetype>
<groupId>io.github.sukgu</groupId>
<artifactId>automation</artifactId>
<version>0.1.4.1</version>
<version>0.1.5</version>
<repository>https://github.com/sukgu/shadow-automation-selenium</repository>
<description>This project automates shadow-dom elements using java selenium</description>
</archetype>
Expand Down
45 changes: 21 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.sukgu</groupId>
<artifactId>automation</artifactId>
<version>0.1.4.1</version>
<version>0.1.5</version>

<name>automation</name>
<description>This project automates shadow-dom elements using java selenium</description>
Expand Down Expand Up @@ -36,20 +36,26 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<hamcrest-all.version>1.3</hamcrest-all.version>
<java.version>1.8</java.version>
<java.version>11</java.version>
<junit-jupiter.version>5.4.0</junit-jupiter.version>
<junit-jupiter-engine-version>5.4.0</junit-jupiter-engine-version>
<junit-vintage-engine-version>5.4.0</junit-vintage-engine-version>
<junit-platform-launcher.version>1.4.0</junit-platform-launcher.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<maven.compiler.target>11</maven.compiler.target>
<maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven.compiler.source>11</maven.compiler.source>
<maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<selenium.version>3.14.0</selenium.version>
<webdrivermanager.version>3.8.1</webdrivermanager.version>
<maven.release.plugin.version>2.5.3</maven.release.plugin.version>
<cobertura.maven.plugin.version>2.7</cobertura.maven.plugin.version>
<nexus.staging.maven.plugin.version>1.6.7</nexus.staging.maven.plugin.version>
<maven.gpg.plugin.version>1.5</maven.gpg.plugin.version>
<maven.javadoc.plugin.version>3.6.3</maven.javadoc.plugin.version>
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<selenium.version>4.16.1</selenium.version>
<webdrivermanager.version>5.6.2</webdrivermanager.version>
<selenium-chrome-driver.version>${selenium.version}</selenium-chrome-driver.version>
<selenium-firefox-driver.version>${selenium.version}</selenium-firefox-driver.version>
</properties>
Expand Down Expand Up @@ -125,15 +131,6 @@
<optional>true</optional>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>${selenium.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
Expand Down Expand Up @@ -195,7 +192,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>${maven.source.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -208,7 +205,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>${maven.javadoc.plugin.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -221,7 +218,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>${maven.gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -235,7 +232,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<version>${nexus.staging.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -247,7 +244,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<version>${cobertura.maven.plugin.version}</version>
<configuration>
<formats>
<format>html</format>
Expand All @@ -259,7 +256,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>${maven.release.plugin.version}</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>true</useReleaseProfile>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/sukgu/Shadow.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
Expand Down Expand Up @@ -183,7 +184,7 @@ public Boolean apply(WebDriver driver) {
}
};
try {
WebDriverWait wait = new WebDriverWait(driver, 30);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(expectation);
} catch (Throwable error) {
//Assertions.fail("Timeout waiting for Page Load Request to complete.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/sukgu/support/BaseBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected BaseBy(String selector, String selectorType) {
this.selectorType = selectorType;
}

private final WebDriver getWebDriver(SearchContext context) {
protected final WebDriver getWebDriver(SearchContext context) {
WebDriver webDriver;

if (context instanceof RemoteWebElement) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/github/sukgu/AnnotationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void testAllElementsXPathWithId() {

@AfterAll
public static void tearDownAll() {
driver.close();
driver.quit();
}


Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/github/sukgu/LocalFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void testAllElementsXPathWithId() {

@AfterAll
public static void tearDownAll() {
driver.close();
driver.quit();
}

// Utilities
Expand Down
18 changes: 10 additions & 8 deletions src/test/java/io/github/sukgu/ShadowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public class ShadowTest {

private final static String baseUrl = "https://www.virustotal.com";
// private static final String urlLocator = "a[data-route='url']";
private static final String urlLocator = "vt-ui-shell vt-ui-button[data-route='url']";
private static final String urlLocator = "home-view a[data-route='url']";
private static final String pageHeading = "home-view div.container";
private static final boolean debug = Boolean
.parseBoolean(getPropertyEnv("DEBUG", "false"));;
private static WebDriver driver = null;
Expand Down Expand Up @@ -91,15 +92,16 @@ public void testGetAllObject() {
public void testAPICalls1() {
WebElement element = shadow.findElements(urlLocator).get(0);

WebElement element1 = shadow.getNextSiblingElement(element);
assertThat(element1, notNullValue());
WebElement element1 = shadow.getParentElement(element);
WebElement element2 = shadow.getNextSiblingElement(element1);
assertThat(element2, notNullValue());
// TODO: compare siblings
}

@Test
public void testAPICalls2() {
WebElement element = shadow.findElements(urlLocator).get(0);
List<WebElement> elements = shadow.findElements(element, "div");
WebElement element = shadow.findElements(pageHeading).get(0);
List<WebElement> elements = shadow.findElements(element, "p");
assertThat(elements, notNullValue());
assertThat(elements.size(), greaterThan(0));
}
Expand All @@ -114,7 +116,7 @@ public void testAPICalls3() {

@Test
public void testAPICalls4() {
WebElement element = shadow.findElement(urlLocator);
WebElement element = shadow.findElement(pageHeading);
List<WebElement> elements = shadow.getChildElements(element);
assertThat(elements, notNullValue());
assertThat(elements.size(), greaterThan(0));
Expand All @@ -123,7 +125,7 @@ public void testAPICalls4() {
@Test
public void testAPICalls5() {
List<WebElement> elements = shadow
.findElements(shadow.findElement(urlLocator), "#wrapperLink");
.findElements(shadow.findElement(pageHeading), ".omnibar");
assertThat(elements, notNullValue());
assertThat(elements.size(), greaterThan(0));
err.println(String.format("Found %d elements: ", elements.size()));
Expand All @@ -138,7 +140,7 @@ public void tearDown() {

@AfterAll
public static void tearDownAll() {
driver.close();
driver.quit();
}

public static String getPropertyEnv(String name, String defaultValue) {
Expand Down

0 comments on commit 3376e82

Please sign in to comment.