Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@

import com.nordstrom.automation.selenium.model.Page;

/**
* This class is the model for the target view of the sample application used by the Appium Macintosh unit test.
*/
public class MacPage extends Page {
public class MacDocumentPage extends Page {

/**
* Constructor for main view context.
*
* @param driver driver object
*/
public MacPage(WebDriver driver) {
super(driver);
}
public MacDocumentPage(WebDriver driver) {
super(driver);
}

/**
* This enumeration defines element locator constants.
*/
protected enum Using implements ByEnum {
/** text field */
EDIT_FIELD(By.className("XCUIElementTypeTextView"));
TEXT_VIEW(By.id("First Text View"));

private final By locator;

Expand All @@ -44,7 +40,7 @@ public By locator() {
* @param keys string to type into text field
*/
public void modifyDocument(String keys) {
findElement(Using.EDIT_FIELD).sendKeys(keys);
findElement(Using.TEXT_VIEW).sendKeys(keys);
}

/**
Expand All @@ -53,7 +49,7 @@ public void modifyDocument(String keys) {
* @return text field content
*/
public String accessDocument() {
return findElement(Using.EDIT_FIELD).getText();
return findElement(Using.TEXT_VIEW).getText();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.nordstrom.automation.selenium.examples;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import com.nordstrom.automation.selenium.model.Page;

/**
* This class is the model for the target view of the sample application used by the Appium Macintosh unit test.
*/
public class MacLaunchPage extends Page {

/**
* Constructor for main view context.
*
* @param driver driver object
*/
public MacLaunchPage(WebDriver driver) {
super(driver);
}

/**
* This enumeration defines element locator constants.
*/
protected enum Using implements ByEnum {
NEW_DOCUMENT(By.id("New Document"));

private final By locator;

Using(By locator) {
this.locator = locator;
}

@Override
public By locator() {
return locator;
}
}

public MacDocumentPage openNewDocument() {
findElement(Using.NEW_DOCUMENT).click();
setWindowState(WindowState.WILL_CLOSE);
MacDocumentPage newPage = new MacDocumentPage(driver);
newPage.setWindowState(WindowState.WILL_CLOSE);
return newPage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.UnsupportedCommandException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -139,7 +140,7 @@ public Object intercept(@This final Object obj, @Origin final Method method, @Al
driver.switchTo().alert();
// alert is shown
hasDialog = true;
} catch (NoAlertPresentException eaten) {
} catch (NoAlertPresentException | UnsupportedCommandException eaten) {
try {
// get stale wait reference element by XPath
reference = driver.findElement(By.xpath("//*"));
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/com/nordstrom/automation/selenium/mac/MacTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
import org.testng.annotations.Test;

import com.nordstrom.automation.selenium.annotations.InitialPage;
import com.nordstrom.automation.selenium.examples.MacPage;
import com.nordstrom.automation.selenium.examples.MacDocumentPage;
import com.nordstrom.automation.selenium.examples.MacLaunchPage;
import com.nordstrom.automation.selenium.platform.TargetPlatform;
import com.nordstrom.automation.selenium.support.TestNgTargetBase;

@InitialPage(MacPage.class)
@InitialPage(MacLaunchPage.class)
public class MacTest extends TestNgTargetBase {

@Test
@TargetPlatform(MAC_APP_NAME)
public void testEditing() {
MacPage page = getInitialPage();
page.modifyDocument("Hello world!");
assertEquals(page.accessDocument(), "Hello world!");
MacLaunchPage launchPage = getInitialPage();
MacDocumentPage documentPage = launchPage.openNewDocument();
documentPage.modifyDocument("Hello world!");
assertEquals(documentPage.accessDocument(), "Hello world!");
}

}