Skip to content

Commit 3376e82

Browse files
authored
Merge pull request #70 from sukgu/dev
Shadow 0.1.5 for Selenium 4
2 parents aa2052b + d88ed1a commit 3376e82

File tree

8 files changed

+45
-41
lines changed

8 files changed

+45
-41
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ You can use this plugin by adding jar file or by including maven dependency in y
8282
`public void highlight(WebElement element, String color, Integer timeInMiliSeconds)` : highlight method.
8383

8484
`public void highlight(WebElement element)` : highlight method highlight in red color.
85-
85+
86+
### What's New
87+
##### We support now Selenium version 4 with release of Shadow version 0.1.5
88+
##### Java 11 and Selenium 4.16.1 to be used with Shadow 0.1.5
89+
8690
###### How to use this plugin:
8791
You will have to dependency in your project.
8892

@@ -91,17 +95,17 @@ You can use this plugin by adding jar file or by including maven dependency in y
9195
<dependency>
9296
<groupId>io.github.sukgu</groupId>
9397
<artifactId>automation</artifactId>
94-
<version>0.1.4.1</version>
98+
<version>0.1.5</version>
9599
</dependency>
96100
```
97101

98102
**Gradle**
99103
```
100-
implementation 'io.github.sukgu:automation:0.1.4.1'
104+
implementation 'io.github.sukgu:automation:0.1.5'
101105
```
102106

103107

104-
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
108+
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
105109

106110
## Selector:
107111
###### Examples:

catalog.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<archetype>
66
<groupId>io.github.sukgu</groupId>
77
<artifactId>automation</artifactId>
8-
<version>0.1.4.1</version>
8+
<version>0.1.5</version>
99
<repository>https://github.com/sukgu/shadow-automation-selenium</repository>
1010
<description>This project automates shadow-dom elements using java selenium</description>
1111
</archetype>

pom.xml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.github.sukgu</groupId>
66
<artifactId>automation</artifactId>
7-
<version>0.1.4.1</version>
7+
<version>0.1.5</version>
88

99
<name>automation</name>
1010
<description>This project automates shadow-dom elements using java selenium</description>
@@ -36,20 +36,26 @@
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3737
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3838
<hamcrest-all.version>1.3</hamcrest-all.version>
39-
<java.version>1.8</java.version>
39+
<java.version>11</java.version>
4040
<junit-jupiter.version>5.4.0</junit-jupiter.version>
4141
<junit-jupiter-engine-version>5.4.0</junit-jupiter-engine-version>
4242
<junit-vintage-engine-version>5.4.0</junit-vintage-engine-version>
4343
<junit-platform-launcher.version>1.4.0</junit-platform-launcher.version>
44-
<maven.compiler.target>1.8</maven.compiler.target>
45-
<maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
46-
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
47-
<maven.compiler.source>1.8</maven.compiler.source>
48-
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
44+
<maven.compiler.target>11</maven.compiler.target>
45+
<maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
46+
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
47+
<maven.compiler.source>11</maven.compiler.source>
48+
<maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
4949
<maven.compiler.target>${java.version}</maven.compiler.target>
5050
<maven.compiler.source>${java.version}</maven.compiler.source>
51-
<selenium.version>3.14.0</selenium.version>
52-
<webdrivermanager.version>3.8.1</webdrivermanager.version>
51+
<maven.release.plugin.version>2.5.3</maven.release.plugin.version>
52+
<cobertura.maven.plugin.version>2.7</cobertura.maven.plugin.version>
53+
<nexus.staging.maven.plugin.version>1.6.7</nexus.staging.maven.plugin.version>
54+
<maven.gpg.plugin.version>1.5</maven.gpg.plugin.version>
55+
<maven.javadoc.plugin.version>3.6.3</maven.javadoc.plugin.version>
56+
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
57+
<selenium.version>4.16.1</selenium.version>
58+
<webdrivermanager.version>5.6.2</webdrivermanager.version>
5359
<selenium-chrome-driver.version>${selenium.version}</selenium-chrome-driver.version>
5460
<selenium-firefox-driver.version>${selenium.version}</selenium-firefox-driver.version>
5561
</properties>
@@ -125,15 +131,6 @@
125131
<optional>true</optional>
126132
</dependency>
127133

128-
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
129-
<dependency>
130-
<groupId>org.seleniumhq.selenium</groupId>
131-
<artifactId>selenium-server</artifactId>
132-
<version>${selenium.version}</version>
133-
<scope>compile</scope>
134-
<optional>true</optional>
135-
</dependency>
136-
137134
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
138135
<dependency>
139136
<groupId>org.seleniumhq.selenium</groupId>
@@ -195,7 +192,7 @@
195192
<plugin>
196193
<groupId>org.apache.maven.plugins</groupId>
197194
<artifactId>maven-source-plugin</artifactId>
198-
<version>2.2.1</version>
195+
<version>${maven.source.plugin.version}</version>
199196
<executions>
200197
<execution>
201198
<id>attach-sources</id>
@@ -208,7 +205,7 @@
208205
<plugin>
209206
<groupId>org.apache.maven.plugins</groupId>
210207
<artifactId>maven-javadoc-plugin</artifactId>
211-
<version>2.9.1</version>
208+
<version>${maven.javadoc.plugin.version}</version>
212209
<executions>
213210
<execution>
214211
<id>attach-javadocs</id>
@@ -221,7 +218,7 @@
221218
<plugin>
222219
<groupId>org.apache.maven.plugins</groupId>
223220
<artifactId>maven-gpg-plugin</artifactId>
224-
<version>1.5</version>
221+
<version>${maven.gpg.plugin.version}</version>
225222
<executions>
226223
<execution>
227224
<id>sign-artifacts</id>
@@ -235,7 +232,7 @@
235232
<plugin>
236233
<groupId>org.sonatype.plugins</groupId>
237234
<artifactId>nexus-staging-maven-plugin</artifactId>
238-
<version>1.6.7</version>
235+
<version>${nexus.staging.maven.plugin.version}</version>
239236
<extensions>true</extensions>
240237
<configuration>
241238
<serverId>ossrh</serverId>
@@ -247,7 +244,7 @@
247244
<plugin>
248245
<groupId>org.codehaus.mojo</groupId>
249246
<artifactId>cobertura-maven-plugin</artifactId>
250-
<version>2.7</version>
247+
<version>${cobertura.maven.plugin.version}</version>
251248
<configuration>
252249
<formats>
253250
<format>html</format>
@@ -259,7 +256,7 @@
259256
<plugin>
260257
<groupId>org.apache.maven.plugins</groupId>
261258
<artifactId>maven-release-plugin</artifactId>
262-
<version>2.5.3</version>
259+
<version>${maven.release.plugin.version}</version>
263260
<configuration>
264261
<autoVersionSubmodules>true</autoVersionSubmodules>
265262
<useReleaseProfile>true</useReleaseProfile>

src/main/java/io/github/sukgu/Shadow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.InputStream;
66
import java.io.InputStreamReader;
77
import java.lang.reflect.Method;
8+
import java.time.Duration;
89
import java.util.ArrayList;
910
import java.util.Arrays;
1011
import java.util.LinkedList;
@@ -183,7 +184,7 @@ public Boolean apply(WebDriver driver) {
183184
}
184185
};
185186
try {
186-
WebDriverWait wait = new WebDriverWait(driver, 30);
187+
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
187188
wait.until(expectation);
188189
} catch (Throwable error) {
189190
//Assertions.fail("Timeout waiting for Page Load Request to complete.");

src/main/java/io/github/sukgu/support/BaseBy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected BaseBy(String selector, String selectorType) {
2121
this.selectorType = selectorType;
2222
}
2323

24-
private final WebDriver getWebDriver(SearchContext context) {
24+
protected final WebDriver getWebDriver(SearchContext context) {
2525
WebDriver webDriver;
2626

2727
if (context instanceof RemoteWebElement) {

src/test/java/io/github/sukgu/AnnotationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void testAllElementsXPathWithId() {
173173

174174
@AfterAll
175175
public static void tearDownAll() {
176-
driver.close();
176+
driver.quit();
177177
}
178178

179179

src/test/java/io/github/sukgu/LocalFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public void testAllElementsXPathWithId() {
327327

328328
@AfterAll
329329
public static void tearDownAll() {
330-
driver.close();
330+
driver.quit();
331331
}
332332

333333
// Utilities

src/test/java/io/github/sukgu/ShadowTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public class ShadowTest {
2424

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

94-
WebElement element1 = shadow.getNextSiblingElement(element);
95-
assertThat(element1, notNullValue());
95+
WebElement element1 = shadow.getParentElement(element);
96+
WebElement element2 = shadow.getNextSiblingElement(element1);
97+
assertThat(element2, notNullValue());
9698
// TODO: compare siblings
9799
}
98100

99101
@Test
100102
public void testAPICalls2() {
101-
WebElement element = shadow.findElements(urlLocator).get(0);
102-
List<WebElement> elements = shadow.findElements(element, "div");
103+
WebElement element = shadow.findElements(pageHeading).get(0);
104+
List<WebElement> elements = shadow.findElements(element, "p");
103105
assertThat(elements, notNullValue());
104106
assertThat(elements.size(), greaterThan(0));
105107
}
@@ -114,7 +116,7 @@ public void testAPICalls3() {
114116

115117
@Test
116118
public void testAPICalls4() {
117-
WebElement element = shadow.findElement(urlLocator);
119+
WebElement element = shadow.findElement(pageHeading);
118120
List<WebElement> elements = shadow.getChildElements(element);
119121
assertThat(elements, notNullValue());
120122
assertThat(elements.size(), greaterThan(0));
@@ -123,7 +125,7 @@ public void testAPICalls4() {
123125
@Test
124126
public void testAPICalls5() {
125127
List<WebElement> elements = shadow
126-
.findElements(shadow.findElement(urlLocator), "#wrapperLink");
128+
.findElements(shadow.findElement(pageHeading), ".omnibar");
127129
assertThat(elements, notNullValue());
128130
assertThat(elements.size(), greaterThan(0));
129131
err.println(String.format("Found %d elements: ", elements.size()));
@@ -138,7 +140,7 @@ public void tearDown() {
138140

139141
@AfterAll
140142
public static void tearDownAll() {
141-
driver.close();
143+
driver.quit();
142144
}
143145

144146
public static String getPropertyEnv(String name, String defaultValue) {

0 commit comments

Comments
 (0)