Skip to content

Commit 8de39e7

Browse files
committed
Merge branch 'develop'
2 parents 3f52664 + c16783f commit 8de39e7

File tree

9 files changed

+93
-16
lines changed

9 files changed

+93
-16
lines changed

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.12.0</version>
12+
<version>0.12.1</version>
1313
</parent>
1414

1515
<name>pogen4selenium-api</name>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public interface PageObjectParent<PAGEOBJECT extends PageObjectParent<PAGEOBJECT
3131
*/
3232
PAGEOBJECT waitForPageToContainText(String text);
3333

34+
/**
35+
* Wait as long as text is displayed
36+
* @param text the text to search
37+
* @param timeout the timout to use
38+
* @return next fluent interface
39+
*/
40+
PAGEOBJECT waitForPageToContainText(String text, Duration timeout);
3441

3542
/**
3643
* Allows to do inline assertions done with your favourite test tools without the need to create local variables to keep state.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ public <OPO extends PageObjectParent<OPO>> OPO execute(ExecuteBlock<PAGEOBJECT,O
6464
}
6565

6666
protected void waitUntilUrl(String urlRegex) {
67-
PageObjectUtilities.waitForiPageToHaveMatchingUrl(driver, urlRegex);
67+
PageObjectUtilities.waitForPageToHaveMatchingUrl(driver, urlRegex);
6868
}
69+
6970

7071
protected void waitForElementToBeInteractable(String xpath) {
7172
waitForElementToBeInteractable(By.xpath(xpath));
@@ -86,7 +87,11 @@ public PAGEOBJECT waitForPageToContainText(String text) {
8687
return (PAGEOBJECT) this;
8788
}
8889

89-
90+
@Override
91+
public PAGEOBJECT waitForPageToContainText(String text, Duration timeout) {
92+
PageObjectUtilities.waitUntilPageSourceContains(driver, text, timeout);
93+
return (PAGEOBJECT) this;
94+
}
9095

9196
public WebElement waitForElementToBeInteractable(ExpectedCondition<WebElement> expectedCondition) {
9297
Wait<WebDriver> wait =

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

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,24 @@ private PageObjectUtilities(){
2929
* @param driver the web driver
3030
* @param urlRegex the regular expression that the url must match
3131
*/
32-
public static void waitForiPageToHaveMatchingUrl(WebDriver driver, String urlRegex) {
32+
public static void waitForPageToHaveMatchingUrl(WebDriver driver, String urlRegex) {
33+
waitForPageToHaveMatchingUrl(driver, urlRegex, Duration.ofSeconds(25));
34+
}
35+
36+
/**
37+
* Waits for page to have a matching url.
38+
* @param driver the web driver
39+
* @param urlRegex the regular expression that the url must match
40+
* @param timeout the timeout
41+
*/
42+
public static void waitForPageToHaveMatchingUrl(WebDriver driver, String urlRegex, Duration timeout) {
3343
Wait<WebDriver> wait =
3444
new FluentWait<>(driver)
35-
.withTimeout(Duration.ofSeconds(25))
45+
.withTimeout(timeout)
3646
.pollingEvery(Duration.ofMillis(300));
3747

3848
wait.until(ExpectedConditions.urlMatches(urlRegex));
3949
}
40-
4150

4251

4352
/**
@@ -47,9 +56,20 @@ public static void waitForiPageToHaveMatchingUrl(WebDriver driver, String urlReg
4756
* @return the web element
4857
*/
4958
public static WebElement waitForElementToBeInteractable(WebDriver driver, By by) {
59+
60+
return waitForElementToBeInteractable(driver, by, Duration.ofSeconds(15));
61+
}
62+
63+
/**
64+
* Wait for an element to exist and to be interactable.
65+
* @param driver the web driver
66+
* @param by the locator for the element
67+
* @return the web element
68+
*/
69+
public static WebElement waitForElementToBeInteractable(WebDriver driver, By by, Duration timeout) {
5070
Wait<WebDriver> wait =
5171
new FluentWait<>(driver)
52-
.withTimeout(Duration.ofSeconds(15))
72+
.withTimeout(timeout)
5373
.pollingEvery(Duration.ofMillis(300))
5474
.ignoring(NoSuchElementException.class,ElementNotInteractableException.class);
5575

@@ -64,13 +84,24 @@ public static WebElement waitForElementToBeInteractable(WebDriver driver, By by)
6484
* @return the web element
6585
*/
6686
protected static WebElement waitForElementToBeInteractable(WebDriver driver, WebElement element) {
87+
return waitForElementToBeInteractable(driver, element, Duration.ofSeconds(15));
88+
}
89+
90+
/**
91+
* Wait if passed element is interactable.
92+
* @param driver the web driver
93+
* @param element the element to wait for the condition
94+
* @param timeout the timeout to use
95+
* @return the web element
96+
*/
97+
protected static WebElement waitForElementToBeInteractable(WebDriver driver, WebElement element, Duration timeout) {
6798
if(element == null) {
6899
return null;
69100
}
70101

71102
Wait<WebDriver> wait =
72103
new FluentWait<>(driver)
73-
.withTimeout(Duration.ofSeconds(15))
104+
.withTimeout(timeout)
74105
.pollingEvery(Duration.ofMillis(300))
75106
.ignoring(ElementNotInteractableException.class);
76107

@@ -85,6 +116,17 @@ protected static WebElement waitForElementToBeInteractable(WebDriver driver, Web
85116
* @return the web element
86117
*/
87118
public static WebElement waitForElementToBePresent(WebDriver driver, By by) {
119+
return waitForElementToBePresent(driver, by, Duration.ofSeconds(15));
120+
}
121+
122+
/**
123+
* Wait for element to be present.
124+
* @param driver web driver
125+
* @param by the locator to use
126+
* @param timeout the timeout to use
127+
* @return the web element
128+
*/
129+
public static WebElement waitForElementToBePresent(WebDriver driver, By by, Duration timeout) {
88130
Wait<WebDriver> wait =
89131
new FluentWait<>(driver)
90132
.withTimeout(Duration.ofSeconds(15))
@@ -94,16 +136,27 @@ public static WebElement waitForElementToBePresent(WebDriver driver, By by) {
94136
return wait.until(ExpectedConditions.presenceOfElementLocated(by));
95137

96138
}
139+
97140

98141
/**
99142
* Wait for element to be absent
100143
* @param driver the web driver
101144
* @param element the web element to check
102145
*/
103146
public static void waitForElementToBeAbsent(WebDriver driver, WebElement element) {
147+
waitForElementToBeAbsent(driver, element, Duration.ofSeconds(15));
148+
}
149+
150+
/**
151+
* Wait for element to be absent
152+
* @param driver the web driver
153+
* @param element the web element to check
154+
* @param timeout the timeout to use
155+
*/
156+
public static void waitForElementToBeAbsent(WebDriver driver, WebElement element, Duration timeout) {
104157
Wait<WebDriver> wait =
105158
new FluentWait<>(driver)
106-
.withTimeout(Duration.ofSeconds(15))
159+
.withTimeout(timeout)
107160
.pollingEvery(Duration.ofMillis(300));
108161

109162
wait.until(ExpectedConditions.stalenessOf(element));
@@ -121,7 +174,17 @@ public static void waitUntilPageSourceContains(WebDriver driver, String text) {
121174

122175
}
123176

124-
177+
/**
178+
* Wait until page source contains.
179+
* @param driver the web driver
180+
* @param text the test to search
181+
* @param timeout the timeout to ise
182+
*/
183+
public static void waitUntilPageSourceContains(WebDriver driver, String text, Duration timeout) {
184+
185+
waitForElementToBePresent(driver, By.xpath("//*[text()[contains(.,'" + text + "')]]"), timeout);
186+
187+
}
125188

126189

127190
public static void doPageRefresh(WebDriver driver) {

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.12.0</version>
12+
<version>0.12.1</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.12.0</version>
36+
<version>0.12.1</version>
3737
</dependency>
3838

3939
<dependency>

pogen4selenium-processor/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
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.11.1-SNAPSHOT</version>
6+
<version>0.12.1-SNAPSHOT</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>pogen4selenium-processor</artifactId>

pogen4selenium-processor/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.12.0</version>
12+
<version>0.12.1</version>
1313
</parent>
1414

1515
<name>pogen4selenium-processor</name>

pogen4selenium-processor/src/main/resources/PageObject.tpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public class ${ toImplementHelper.implementationClassName } ${toImplementHelper.
5252
// implement methods
5353
!{for method : methodsToImplement}
5454
@Override
55-
public !{if method.isSynchronized}synchronized!{/if} ${method.methodSignature}{
55+
public ${method.methodSignature}{
5656
57+
!{if method.isSynchronized}synchronized(${ toImplementHelper.implementationClassName }.class){!{/if}
5758
pause(Duration.ofMillis(${method.beforePause}L));
5859

5960
!{for action : method.actions}
@@ -67,6 +68,7 @@ public class ${ toImplementHelper.implementationClassName } ${toImplementHelper.
6768
!{else}
6869
return changePageObjectType(${method.getNextImplClassName}.class).pause(Duration.ofMillis(${method.afterPause}L));
6970
!{/if}
71+
!{if method.isSynchronized}}!{/if}
7072
}
7173
!{/for}
7274

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.toolisticon.pogen4selenium</groupId>
55
<artifactId>pogen4selenium</artifactId>
6-
<version>0.12.0</version>
6+
<version>0.12.1</version>
77
<packaging>pom</packaging>
88
<name>pogen4selenium</name>
99
<description>Please refer to https://github.com/toolisticon/pogen4selenium</description>

0 commit comments

Comments
 (0)