Skip to content

Commit ccf3bba

Browse files
sbabcocScott Babcock
andauthored
Add Mac2 page class/test; final/(un)boxing cleanup (#239)
Co-authored-by: Scott Babcock <scbabco@rei.com>
1 parent d26c460 commit ccf3bba

37 files changed

+160
-74
lines changed

src/main/java/com/nordstrom/automation/selenium/AbstractSeleniumConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ public String resolveString(String propertyName) {
572572
Path path = Paths.get(valuePath);
573573
URL url = path.toUri().toURL();
574574
propertyValue = Resources.toString(url, Charsets.UTF_8);
575-
} catch (IOException e) {
575+
} catch (IOException eaten) {
576576
// nothing to do here
577577
}
578578
}
@@ -665,7 +665,7 @@ public URI getTargetUri() {
665665

666666
try {
667667
targetUri = builder.build().normalize();
668-
} catch (URISyntaxException eaten) { //NOSONAR
668+
} catch (URISyntaxException eaten) {
669669
LOGGER.error("Specified target URI '{}' could not be parsed: {}", builder, eaten.getMessage());
670670
}
671671
}
@@ -857,9 +857,9 @@ private static String getConfigPath(final String path) {
857857
URI uri = getConfigUri(path, url);
858858
File file = new File(uri);
859859
return file.getAbsolutePath();
860-
} catch (URISyntaxException eaten) { //NOSONAR
860+
} catch (URISyntaxException eaten) {
861861
LOGGER.warn("Invalid URL returned by file locator: {}", eaten.getMessage());
862-
} catch (IOException eaten) { //NOSONAR
862+
} catch (IOException eaten) {
863863
LOGGER.warn("Failed to construct file system or extract configuration file: {}", eaten.getMessage());
864864
}
865865
}
@@ -880,7 +880,7 @@ private static URI getConfigUri(final String path, final URL url) throws URISynt
880880
if ("jar".equals(uri.getScheme())) {
881881
try {
882882
FileSystems.newFileSystem(uri, Collections.<String, Object>emptyMap());
883-
} catch (FileSystemAlreadyExistsException eaten) { //NOSONAR
883+
} catch (FileSystemAlreadyExistsException eaten) {
884884
LOGGER.warn("Specified file system already exists: {}", eaten.getMessage());
885885
}
886886

src/main/java/com/nordstrom/automation/selenium/core/DriverManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public static void setDriverTimeouts(final WebDriver driver, final SeleniumConfi
184184

185185
try {
186186
timeouts.pageLoadTimeout(WaitType.PAGE_LOAD.getInterval(config), TimeUnit.SECONDS);
187-
} catch (WebDriverException e) {
187+
} catch (WebDriverException eaten) {
188188
// unsupported feature: nothing to do here
189189
}
190190
}
@@ -242,13 +242,13 @@ public static Optional<WebDriver> closeDriver(final Object obj) {
242242

243243
try {
244244
((JavascriptExecutor) driver).executeScript("return window.stop");
245-
} catch (WebDriverException | UnsupportedOperationException e) { //NOSONAR
245+
} catch (WebDriverException | UnsupportedOperationException eaten) {
246246
// Let's make sure our graceful shutdown process doesn't cause failures.
247247
}
248248

249249
try {
250250
driver.switchTo().alert().dismiss();
251-
} catch (WebDriverException e) { //NOSONAR
251+
} catch (WebDriverException eaten) {
252252
// The driver throws an exception if no alert is present. This is normal and unavoidable.
253253
}
254254

src/main/java/com/nordstrom/automation/selenium/core/GridUtility.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static boolean isHostActive(final URL hostUrl, final String request) {
8585
try {
8686
HttpResponse response = getHttpResponse(hostUrl, request);
8787
return (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK);
88-
} catch (IOException e) { //NOSONAR
88+
} catch (IOException eaten) {
8989
// nothing to do here
9090
}
9191
return false;
@@ -320,7 +320,7 @@ public static boolean isThisMyIpAddress(final InetAddress addr) {
320320
// Check if the address is defined on any interface
321321
try {
322322
return NetworkInterface.getByInetAddress(addr) != null;
323-
} catch (SocketException e) { //NOSONAR
323+
} catch (SocketException e) {
324324
LOGGER.warn("Attempt to associate IP address with adapter triggered I/O exception: {}", e.getMessage());
325325
return false;
326326
}

src/main/java/com/nordstrom/automation/selenium/core/LocalSeleniumGrid.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static SeleniumGrid create(SeleniumConfig config, final Path hubConfigPat
8686

8787
String launcherClassName = config.getString(SeleniumSettings.GRID_LAUNCHER.key());
8888
String[] dependencyContexts = config.getDependencyContexts();
89-
Integer hubPort = config.getInteger(SeleniumSettings.HUB_PORT.key(), Integer.valueOf(0));
89+
Integer hubPort = config.getInteger(SeleniumSettings.HUB_PORT.key(), 0);
9090
String workingDir = config.getString(SeleniumSettings.GRID_WORKING_DIR.key());
9191
Path workingPath = (workingDir == null || workingDir.isEmpty()) ? null : Paths.get(workingDir);
9292
Path outputPath = GridUtility.getOutputPath(config, GridRole.HUB);
@@ -254,9 +254,9 @@ public static LocalGridServer create(final String launcherClassName, final Strin
254254

255255
Integer portNum = port;
256256
// if port auto-select spec'd
257-
if (portNum.intValue() == 0) {
257+
if (portNum == 0) {
258258
// acquire available port
259-
portNum = Integer.valueOf(PortProber.findFreePort());
259+
portNum = PortProber.findFreePort();
260260
}
261261

262262
// specify server port
@@ -299,8 +299,8 @@ public static LocalGridServer create(final String launcherClassName, final Strin
299299

300300
public static class LocalGridServer extends GridServer {
301301

302-
private CommandLine process;
303-
private Map<String, String> personalities = new HashMap<>();
302+
private final CommandLine process;
303+
private final Map<String, String> personalities = new HashMap<>();
304304

305305
/**
306306
* Constructor for local Grid server object.

src/main/java/com/nordstrom/automation/selenium/examples/ExamplePage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public static URI setHubAsTarget() {
236236
.setPort(hubUrl.getPort())
237237
.build().normalize();
238238
config.setTargetUri(targetUri);
239-
} catch (URISyntaxException e) {
239+
} catch (URISyntaxException eaten) {
240240
// nothing to do here
241241
}
242242
return targetUri;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.nordstrom.automation.selenium.examples;
2+
3+
import org.openqa.selenium.By;
4+
import org.openqa.selenium.WebDriver;
5+
6+
import com.nordstrom.automation.selenium.model.Page;
7+
8+
public class MacPage extends Page {
9+
10+
public MacPage(WebDriver driver) {
11+
super(driver);
12+
}
13+
14+
protected enum Using implements ByEnum {
15+
EDIT_FIELD(By.className("XCUIElementTypeTextView"));
16+
17+
private By locator;
18+
19+
Using(By locator) {
20+
this.locator = locator;
21+
}
22+
23+
@Override
24+
public By locator() {
25+
return locator;
26+
}
27+
}
28+
29+
public void modifyDocument(String keys) {
30+
findElement(Using.EDIT_FIELD).sendKeys(keys);
31+
}
32+
33+
public String accessDocument() {
34+
return findElement(Using.EDIT_FIELD).getText();
35+
}
36+
37+
}

src/main/java/com/nordstrom/automation/selenium/exceptions/ComponentStillDisplayedTimeoutException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* This exception is associated with the {@link PageComponent#componentIsHidden()} condition and indicates that the
99
* indicated page component was still displayed when the timeout interval expired.
1010
*/
11-
public class ComponentStillDisplayedTimeoutException extends TimeoutException { //NOSONAR
11+
public class ComponentStillDisplayedTimeoutException extends TimeoutException {
1212

1313
private static final long serialVersionUID = 5397614393701035129L;
1414

src/main/java/com/nordstrom/automation/selenium/exceptions/ComponentStillInvisibleTimeoutException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* This exception is associated with the {@link PageComponent#componentIsVisible()} condition and indicates that the
99
* indicated page component was still invisible when the timeout interval expired.
1010
*/
11-
public class ComponentStillInvisibleTimeoutException extends TimeoutException { //NOSONAR
11+
public class ComponentStillInvisibleTimeoutException extends TimeoutException {
1212

1313
private static final long serialVersionUID = 7779370358344583623L;
1414

src/main/java/com/nordstrom/automation/selenium/exceptions/ConditionStillInvalidTimeoutException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* This exception is associated with the {@link Coordinators#has(com.google.common.base.Function)} wrapper method
99
* and indicates that the wrapped condition was still returning a 'negative' result when the timeout interval expired.
1010
*/
11-
public class ConditionStillInvalidTimeoutException extends TimeoutException { //NOSONAR
11+
public class ConditionStillInvalidTimeoutException extends TimeoutException {
1212

1313
private static final long serialVersionUID = -5012103332012897882L;
1414

src/main/java/com/nordstrom/automation/selenium/exceptions/ConditionStillValidTimeoutException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* This exception is associated with the {@link Coordinators#not(com.google.common.base.Function)} wrapper method
99
* and indicates that the wrapped condition was still returning a 'positive' result when the timeout interval expired.
1010
*/
11-
public class ConditionStillValidTimeoutException extends TimeoutException { //NOSONAR
11+
public class ConditionStillValidTimeoutException extends TimeoutException {
1212

1313
private static final long serialVersionUID = -1194280527172574112L;
1414

0 commit comments

Comments
 (0)