Skip to content

Commit 754920d

Browse files
committed
Merge branch 'develop'
2 parents a189d0d + 984cdda commit 754920d

File tree

17 files changed

+89
-32
lines changed

17 files changed

+89
-32
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# pogen4selenium - a page object generator 4 selenium
22

33
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.pogen4selenium/pogen4selenium/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.pogen4selenium/pogen4selenium)
4+
[![Maven Central](https://maven-badges.sml.io/sonatype-central/io.toolisticon.pogen4selenium/pogen4selenium/badge.svg)](https://maven-badges.sml.io/sonatype-central/io.toolisticon.pogen4selenium/pogen4selenium)
45

56

67
# Why you should use this project?

pogen4selenium-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>io.toolisticon.pogen4selenium</groupId>
1111
<artifactId>pogen4selenium</artifactId>
12-
<version>0.9.1</version>
12+
<version>0.10.0</version>
1313
</parent>
1414

1515
<name>pogen4selenium-api</name>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package io.toolisticon.pogen4selenium.api;
2+
3+
import java.lang.reflect.InvocationTargetException;
4+
5+
import org.openqa.selenium.WebDriver;
6+
7+
public interface CommonParentInterface {
8+
9+
/**
10+
* Gets the seleium driver.
11+
* @return the selenium driver currently used
12+
*/
13+
WebDriver getDriver();
14+
15+
/**
16+
* Allows the creation of page object instances while using the fluent interface
17+
* @param <T>
18+
* @param pageObjectInterfaceType
19+
* @return
20+
*/
21+
default <T extends PageObjectParent<T>> T getPageObjectInstance(Class<T> pageObjectInterfaceType) {
22+
23+
return getPageObjectInstance(pageObjectInterfaceType, getDriver());
24+
25+
}
26+
27+
/**
28+
* Allows the creation of page object instances while using the fluent interface
29+
* @param <T>
30+
* @param pageObjectInterfaceType
31+
* @return
32+
*/
33+
@SuppressWarnings("unchecked")
34+
public static <T extends PageObjectParent<T>> T getPageObjectInstance(Class<T> pageObjectInterfaceType, WebDriver driver) {
35+
36+
try {
37+
38+
Class<?> clazz = Class.forName(pageObjectInterfaceType.getPackageName() + "." + pageObjectInterfaceType.getSimpleName() + "Impl");
39+
return (T) clazz.getConstructor(WebDriver.class).newInstance(driver);
40+
41+
} catch (ClassCastException |ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
42+
throw new IllegalArgumentException("Couldn't create instance for PageObject '" + pageObjectInterfaceType.getCanonicalName() + "'", e);
43+
}
44+
45+
}
46+
47+
48+
49+
}

pogen4selenium-api/src/main/java/io/toolisticon/pogen4selenium/api/PageObjectParent.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,21 @@
22

33
import java.time.Duration;
44

5-
import org.openqa.selenium.WebDriver;
6-
75
import io.toolisticon.pogen4selenium.runtime.AssertionInterface;
86
import io.toolisticon.pogen4selenium.runtime.ExecuteBlock;
97

108
/**
119
* The page object parent interface. Must be extended by all interfaces annotated with {@link PageObject}
1210
* @param <PAGEOBJECT> The page object type
1311
*/
14-
public interface PageObjectParent<PAGEOBJECT extends PageObjectParent<PAGEOBJECT>> {
12+
public interface PageObjectParent<PAGEOBJECT extends PageObjectParent<PAGEOBJECT>> extends CommonParentInterface {
1513

1614
/**
1715
* Verifies all elements marked via {@link PageObjectElement} annotated fields according to the configuration in the annotation.
1816
* @return The next fluent interface
1917
*/
2018
PAGEOBJECT verify();
2119

22-
/**
23-
* Gets the seleium driver.
24-
* @return the selenium driver currently used
25-
*/
26-
WebDriver getDriver();
27-
2820
/**
2921
* Applies a fixed time pause.
3022
* @param duration the duration to pause
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.toolisticon.pogen4selenium.runtime;
2+
3+
public interface CommonPageObjectCreator {
4+
5+
}

pogen4selenium-api/src/main/java/io/toolisticon/pogen4selenium/runtime/DataObjectParentImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
import org.openqa.selenium.support.ui.Wait;
1515

1616
import io.toolisticon.pogen4selenium.api._By;
17+
import io.toolisticon.pogen4selenium.api.CommonParentInterface;
1718
import io.toolisticon.pogen4selenium.api.ExtractDataValue;
1819

19-
public class DataObjectParentImpl implements CommonByLocators{
20+
public class DataObjectParentImpl implements CommonByLocators, CommonParentInterface{
2021

2122
protected final WebDriver driver;
2223
private final WebElement relativeParentWebElement;
@@ -26,6 +27,7 @@ protected DataObjectParentImpl(WebDriver driver, WebElement relativeParentWebEle
2627
this.relativeParentWebElement = relativeParentWebElement;
2728
}
2829

30+
@Override
2931
public WebDriver getDriver() {
3032
return this.driver;
3133
}

pogen4selenium-api/src/main/java/io/toolisticon/pogen4selenium/runtime/PageObjectParentImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public WebDriver getDriver() {
3939
return this.driver;
4040
}
4141

42-
42+
4343
@Override
4444
public PAGEOBJECT pause(Duration duration) {
4545
new Actions(driver).pause(duration).perform();

pogen4selenium-example/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>io.toolisticon.pogen4selenium</groupId>
1111
<artifactId>pogen4selenium</artifactId>
12-
<version>0.9.1</version>
12+
<version>0.10.0</version>
1313
</parent>
1414

1515
<name>pogen4selenium-example</name>
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>io.toolisticon.pogen4selenium</groupId>
3535
<artifactId>pogen4selenium-api</artifactId>
36-
<version>0.9.1</version>
36+
<version>0.10.0</version>
3737
</dependency>
3838

3939
<dependency>
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<factorypath>
22
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/spiap/spiap-processor/0.11.0/spiap-processor-0.11.0.jar" enabled="true" runInBatchMode="false"/>
33
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/spiap/spiap-api/0.11.0/spiap-api-0.11.0.jar" enabled="true" runInBatchMode="false"/>
4-
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-annotationwrapper-processor/0.30.2/aptk-annotationwrapper-processor-0.30.2.jar" enabled="true" runInBatchMode="false"/>
5-
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-annotationwrapper-api/0.30.2/aptk-annotationwrapper-api-0.30.2.jar" enabled="true" runInBatchMode="false"/>
6-
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-compilermessages-processor/0.30.2/aptk-compilermessages-processor-0.30.2.jar" enabled="true" runInBatchMode="false"/>
7-
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-compilermessages-api/0.30.2/aptk-compilermessages-api-0.30.2.jar" enabled="true" runInBatchMode="false"/>
4+
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-annotationwrapper-processor/0.30.5/aptk-annotationwrapper-processor-0.30.5.jar" enabled="true" runInBatchMode="false"/>
5+
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-annotationwrapper-api/0.30.5/aptk-annotationwrapper-api-0.30.5.jar" enabled="true" runInBatchMode="false"/>
6+
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-compilermessages-processor/0.30.5/aptk-compilermessages-processor-0.30.5.jar" enabled="true" runInBatchMode="false"/>
7+
<factorypathentry kind="VARJAR" id="M2_REPO/io/toolisticon/aptk/aptk-compilermessages-api/0.30.5/aptk-compilermessages-api-0.30.5.jar" enabled="true" runInBatchMode="false"/>
88
<factorypathentry kind="PLUGIN" id="org.eclipse.jst.ws.annotations.core" enabled="false" runInBatchMode="false"/>
99
</factorypath>

pogen4selenium-processor/dependency-reduced-pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>pogen4selenium</artifactId>
55
<groupId>io.toolisticon.pogen4selenium</groupId>
6-
<version>0.9.1-SNAPSHOT</version>
6+
<version>0.9.2-SNAPSHOT</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>pogen4selenium-processor</artifactId>
@@ -75,13 +75,13 @@
7575
<dependency>
7676
<groupId>io.toolisticon.aptk</groupId>
7777
<artifactId>aptk-annotationwrapper-api</artifactId>
78-
<version>0.30.3</version>
78+
<version>0.30.5</version>
7979
<scope>provided</scope>
8080
</dependency>
8181
<dependency>
8282
<groupId>io.toolisticon.aptk</groupId>
8383
<artifactId>aptk-compilermessages-api</artifactId>
84-
<version>0.30.3</version>
84+
<version>0.30.5</version>
8585
<scope>provided</scope>
8686
</dependency>
8787
<dependency>
@@ -117,7 +117,7 @@
117117
<dependency>
118118
<groupId>io.toolisticon.aptk</groupId>
119119
<artifactId>aptk-cute</artifactId>
120-
<version>0.30.3</version>
120+
<version>0.30.5</version>
121121
<scope>test</scope>
122122
</dependency>
123123
<dependency>

0 commit comments

Comments
 (0)