Skip to content

Commit dbd8bb7

Browse files
Merge pull request #18 from digital-delivery-academy/publish-javadocs-issue-#6
Publish javadocs issue #6
2 parents b44b233 + 08f0074 commit dbd8bb7

33 files changed

+500
-203
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ before_install:
1818
- "cp .travis.settings.xml $HOME/.m2/settings.xml"
1919
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
2020
- google-chrome-stable --remote-debugging-port=9222 http://localhost &
21+
- chmod ugo+x scripts/publish-javadocs-to-github-pages.sh
2122

2223
addons:
2324
firefox: latest
@@ -33,7 +34,11 @@ deploy:
3334
- provider: script
3435
script: mvn package com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml -DprojectToken=$CODACY_PROJECT_TOKEN -DapiToken=$CODACY_API_TOKEN
3536
on:
36-
all_branches: true
37+
branch: master
38+
- provider: script
39+
script: bash scripts/publish-javadocs-to-github-pages.sh
40+
on:
41+
tags: true
3742

3843
notifications:
3944
slack: evoco:HMLAFFFsZHDFu6xBw0OyXZrp

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<mockneat.version>0.3.8</mockneat.version>
6363
<versions.maven.plugin.version>2.7</versions.maven.plugin.version>
6464
<jacoco.maven.plugin.version>0.8.5</jacoco.maven.plugin.version>
65+
<javadoc.maven.plugin.version>3.1.1</javadoc.maven.plugin.version>
6566
<joda.time.version>2.7</joda.time.version>
6667
</properties>
6768

@@ -194,6 +195,11 @@
194195
</execution>
195196
</executions>
196197
</plugin>
198+
<plugin>
199+
<groupId>org.apache.maven.plugins</groupId>
200+
<artifactId>maven-javadoc-plugin</artifactId>
201+
<version>${javadoc.maven.plugin.version}</version>
202+
</plugin>
197203
</plugins>
198204
</build>
199205
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#! /usr/bin/env sh
2+
set -ev
3+
workingDir=`pwd`
4+
5+
# Generate javadocs and get current app version
6+
mvn javadoc:javadoc
7+
currentAppVersion=`mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec`
8+
9+
# Get to the Travis build directory, configure git and clone the repo
10+
cd $HOME
11+
git config --global user.email "[email protected]"
12+
git config --global user.name "travis-ci"
13+
git clone --quiet --branch=gh-pages https://${GITHUB_JAVADOCS_PUBLISH_TOKEN}@github.com/digital-delivery-academy/selenium-pom-framework gh-pages > /dev/null
14+
15+
# Commit and Push the Changes
16+
cd gh-pages
17+
cp -Rf ${workingDir}/target/site/apidocs ./javadoc-${currentAppVersion}
18+
git add -f .
19+
git commit -m "Lastest javadoc on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages for app version ${currentAppVersion}"
20+
git push -fq origin gh-pages > /dev/null

src/main/java/uk/co/evoco/pageobjects/BasePageObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class BasePageObject {
1717
/**
1818
* Initiates page elements that are declared as fields annotated @FindBy and makes the WebDriver
1919
* instance available to child classes.
20-
* @param webDriver
20+
* @param webDriver active WebDriver instance
2121
*/
2222
public BasePageObject(WebDriver webDriver) {
2323
PageFactory.initElements(webDriver, this);

src/main/java/uk/co/evoco/tests/BaseAbstractTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public abstract class BaseAbstractTest {
2222
* This will run before every test class.
2323
* This method gets the configuration and constructs the WebDriver instance, the screenshot
2424
* directory and the makes these items accessible.
25-
* @throws IOException
2625
*/
2726
@BeforeAll
2827
public static void beforeAll() {
@@ -34,6 +33,7 @@ public static void beforeAll() {
3433
* This will run before EVERY @Test that extends this class
3534
* The method will create a new instance of WebDriver and a browser and open Google.com
3635
* This ensures we always have a fresh browser window and a guaranteed starting point
36+
* @throws IOException if results directory isn't created or config file cannot be found
3737
*/
3838
@BeforeEach
3939
public void setUp() throws IOException {

src/main/java/uk/co/evoco/webdriver/WebDriverBuilder.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public class WebDriverBuilder {
1818

1919
/**
2020
*
21-
* @param screenshotDirectory
22-
* @return
21+
* @param screenshotDirectory path for the directory storing screenshots
22+
* @return WebDriverBuilder as using builder pattern
2323
*/
2424
public WebDriverBuilder setResultsDirectory(File screenshotDirectory) {
2525
this.screenshotDirectory = screenshotDirectory;
@@ -29,20 +29,21 @@ public WebDriverBuilder setResultsDirectory(File screenshotDirectory) {
2929
/**
3030
* The build method pulls all of the configuration options together and uses them to
3131
* construct an EventFiringWebDriver with the correct configuration for the browser type
32-
* @return EventFiringWebDriver
32+
* @return EventFiringWebDriver representing the configured driver
33+
* @throws IOException if log file for browser driver logs cannot be created
3334
*/
3435
public EventFiringWebDriver build() throws IOException {
3536
switch(TestConfigManager.getInstance().getWebDriverConfig().getBrowserType()) {
3637
case CHROME:
37-
return new ConfiguredChromeDriver(TestConfigManager.getInstance().getWebDriverConfig()).getDriver(this.screenshotDirectory);
38+
return new ConfiguredChromeDriver().getDriver(this.screenshotDirectory);
3839
case FIREFOX:
39-
return new ConfiguredFirefoxDriver(TestConfigManager.getInstance().getWebDriverConfig()).getDriver(this.screenshotDirectory);
40+
return new ConfiguredFirefoxDriver().getDriver(this.screenshotDirectory);
4041
case IE:
41-
return new ConfiguredInternetExplorerDriver(TestConfigManager.getInstance().getWebDriverConfig()).getDriver(this.screenshotDirectory);
42+
return new ConfiguredInternetExplorerDriver().getDriver(this.screenshotDirectory);
4243
case EDGE:
43-
return new ConfiguredEdgeDriver(TestConfigManager.getInstance().getWebDriverConfig()).getDriver(this.screenshotDirectory);
44+
return new ConfiguredEdgeDriver().getDriver(this.screenshotDirectory);
4445
case SAFARI:
45-
return new ConfiguredSafariDriver(TestConfigManager.getInstance().getWebDriverConfig()).getDriver(this.screenshotDirectory);
46+
return new ConfiguredSafariDriver().getDriver(this.screenshotDirectory);
4647
default:
4748
throw new RuntimeException("WebDriverBuilder has no valid target browser set in WebDriverConfig");
4849
}

src/main/java/uk/co/evoco/webdriver/WebDriverListener.java

Lines changed: 124 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,64 +32,114 @@ public class WebDriverListener implements WebDriverEventListener {
3232

3333
/**
3434
* Sets the wait for all of the ExpectedConditions calls that we make here
35-
* @param webDriverWaitTimeout
35+
* @param webDriverWaitTimeout the timeout used for WebDriverWaits
3636
*/
3737
public void setWebdriverWaitTimeout(long webDriverWaitTimeout) {
3838
this.WEBDRIVER_WAIT_TIMEOUT = webDriverWaitTimeout;
3939
}
4040

4141
/**
4242
* Sets the screenshot target directory that will be used for screenshots generated inside onException()
43-
* @param screenshotDirectory
43+
* @param screenshotDirectory the path to the screenshot directory used in onException
4444
*/
4545
public void setScreenshotDirectory(File screenshotDirectory) {
4646
this.screenshotDirectory = screenshotDirectory;
4747
}
4848

49+
/**
50+
*
51+
* @param webDriver active WebDriver instance
52+
*/
4953
public void beforeAlertAccept(WebDriver webDriver) {
5054
// nothing yet
5155
}
5256

57+
/**
58+
*
59+
* @param webDriver active WebDriver instance
60+
*/
5361
public void afterAlertAccept(WebDriver webDriver) {
5462
// nothing yet
5563
}
5664

65+
/**
66+
*
67+
* @param webDriver active WebDriver instance
68+
*/
5769
public void afterAlertDismiss(WebDriver webDriver) {
5870
// nothing yet
5971
}
6072

73+
/**
74+
*
75+
* @param webDriver active WebDriver instance
76+
*/
6177
public void beforeAlertDismiss(WebDriver webDriver) {
6278
// nothing yet
6379
}
6480

81+
/**
82+
*
83+
* @param s String
84+
* @param webDriver active WebDriver instance
85+
*/
6586
public void beforeNavigateTo(String s, WebDriver webDriver) {
6687
// nothing yet
6788
}
6889

90+
/**
91+
*
92+
* @param s String
93+
* @param webDriver active WebDriver instance
94+
*/
6995
public void afterNavigateTo(String s, WebDriver webDriver) {
7096
// nothing yet
7197
}
7298

99+
/**
100+
*
101+
* @param webDriver active WebDriver instance
102+
*/
73103
public void beforeNavigateBack(WebDriver webDriver) {
74104
// nothing yet
75105
}
76106

107+
/**
108+
*
109+
* @param webDriver active WebDriver instance
110+
*/
77111
public void afterNavigateBack(WebDriver webDriver) {
78112
// nothing yet
79113
}
80114

115+
/**
116+
*
117+
* @param webDriver active WebDriver instance
118+
*/
81119
public void beforeNavigateForward(WebDriver webDriver) {
82120
// nothing yet
83121
}
84122

123+
/**
124+
*
125+
* @param webDriver active WebDriver instance
126+
*/
85127
public void afterNavigateForward(WebDriver webDriver) {
86128
// nothing yet
87129
}
88130

131+
/**
132+
*
133+
* @param webDriver active WebDriver instance
134+
*/
89135
public void beforeNavigateRefresh(WebDriver webDriver) {
90136
// nothing yet
91137
}
92138

139+
/**
140+
*
141+
* @param webDriver active WebDriver instance
142+
*/
93143
public void afterNavigateRefresh(WebDriver webDriver) {
94144
// nothing yet
95145
}
@@ -98,14 +148,20 @@ public void afterNavigateRefresh(WebDriver webDriver) {
98148
* Before each webDriver.findBy or @FindBy we want to make sure that we are supply elements
99149
* that are present in the DOM. This ensures that we avoid, to some degree, StaleElementExceptions (although
100150
* this is generally not the best way to avoid those types of exceptions).
101-
* @param by
102-
* @param webElement
103-
* @param webDriver
151+
* @param by locator
152+
* @param webElement active WebElement, already located
153+
* @param webDriver active WebDriver instance
104154
*/
105155
public void beforeFindBy(By by, WebElement webElement, WebDriver webDriver) {
106156
new WebDriverWait(webDriver, WEBDRIVER_WAIT_TIMEOUT).until(ExpectedConditions.presenceOfElementLocated(by));
107157
}
108158

159+
/**
160+
*
161+
* @param by locator
162+
* @param webElement active WebElement, already located
163+
* @param webDriver active WebDriver instance
164+
*/
109165
public void afterFindBy(By by, WebElement webElement, WebDriver webDriver) {
110166
// nothing yet
111167
}
@@ -116,45 +172,82 @@ public void afterFindBy(By by, WebElement webElement, WebDriver webDriver) {
116172
* given time (as little as they need) to be ready to be interacted with.
117173
*
118174
* A valid case for this is where a button may be disabled until form fields are automatically valid.
119-
* @param webElement
120-
* @param webDriver
175+
* @param webElement active WebElement, already located
176+
* @param webDriver active WebDriver instance
121177
*/
122178
public void beforeClickOn(WebElement webElement, WebDriver webDriver) {
123179
new WebDriverWait(webDriver, WEBDRIVER_WAIT_TIMEOUT).until(ExpectedConditions.elementToBeClickable(webElement));
124180
}
125181

182+
/**
183+
*
184+
* @param webElement active WebElement, already located
185+
* @param webDriver active WebDriver instance
186+
*/
126187
public void afterClickOn(WebElement webElement, WebDriver webDriver) {
127188
// nothing yet
128189
}
129190

191+
/**
192+
*
193+
* @param webElement active WebElement, already located
194+
* @param webDriver active WebDriver instance
195+
* @param charSequences character sequence
196+
*/
130197
public void beforeChangeValueOf(WebElement webElement, WebDriver webDriver, CharSequence[] charSequences) {
131198
// nothing yet
132199
}
133200

201+
/**
202+
*
203+
* @param webElement active WebElement, already located
204+
* @param webDriver active WebDriver instance
205+
* @param charSequences character sequence
206+
*/
134207
public void afterChangeValueOf(WebElement webElement, WebDriver webDriver, CharSequence[] charSequences) {
135208
// nothing yet
136209
}
137210

211+
/**
212+
*
213+
* @param s String
214+
* @param webDriver active WebDriver instance
215+
*/
138216
public void beforeScript(String s, WebDriver webDriver) {
139217
// nothing yet
140218
}
141219

220+
/**
221+
*
222+
* @param s String
223+
* @param webDriver active WebDriver instance
224+
*/
142225
public void afterScript(String s, WebDriver webDriver) {
143226
// nothing yet
144227
}
145228

229+
/**
230+
*
231+
* @param s String
232+
* @param webDriver active WebDriver instance
233+
*/
146234
public void beforeSwitchToWindow(String s, WebDriver webDriver) {
147235
// nothing yet
148236
}
149237

238+
/**
239+
*
240+
* @param s String
241+
* @param webDriver active WebDriver instance
242+
*/
150243
public void afterSwitchToWindow(String s, WebDriver webDriver) {
151244
// nothing yet
152245
}
153246

154247
/**
155248
* If we have an exception, lets create a screenshot so we can see the page as it happened.
156-
* @param throwable
157-
* @param webDriver
249+
* @param throwable the thrown exception that we are holding here
250+
* @param webDriver active WebDriver instance
158251
*/
159252
public void onException(Throwable throwable, WebDriver webDriver) {
160253
File scrFile = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);
@@ -171,18 +264,40 @@ public void onException(Throwable throwable, WebDriver webDriver) {
171264
}
172265
}
173266

267+
/**
268+
*
269+
* @param outputType output type
270+
* @param <X> x
271+
*/
174272
public <X> void beforeGetScreenshotAs(OutputType<X> outputType) {
175273
// nothing yet
176274
}
177275

276+
/**
277+
*
278+
* @param outputType output type
279+
* @param x x
280+
* @param <X> x
281+
*/
178282
public <X> void afterGetScreenshotAs(OutputType<X> outputType, X x) {
179283
// nothing yet
180284
}
181285

286+
/**
287+
*
288+
* @param webElement active WebElement, already located
289+
* @param webDriver active WebDriver instance
290+
*/
182291
public void beforeGetText(WebElement webElement, WebDriver webDriver) {
183292
// nothing yet
184293
}
185294

295+
/**
296+
*
297+
* @param webElement active WebElement, already located
298+
* @param webDriver active WebDriver instance
299+
* @param s String
300+
*/
186301
public void afterGetText(WebElement webElement, WebDriver webDriver, String s) {
187302
// nothing yet
188303
}

0 commit comments

Comments
 (0)