Created
December 6, 2018 15:47
-
-
Save sauceaaron/5d42af4f9e28650f3bfd96499921b882 to your computer and use it in GitHub Desktop.
Test Appium session interacting with the Barista API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testCustomerDeviceWithBaristaApi() | |
{ | |
// Create a session for the customer app | |
phone = new AppiumDriver(sauceURL, deviceCapabilities); | |
// Create an API service that interacts with the mobile app | |
baristaAPI = new BaristaAPI(barristUsername, baristaPassword); | |
// Customer logs into mobile app on mobile device | |
phone.findElement(mobileApp.loginScreen.usernameField).sendKeys(customer.username); | |
phone.findElement(mobileApp.loginScreen.passwordField).sendKeys(customer.password); | |
phone.findElement(mobileApp.loginScreen.loginButton).click(); | |
// Customer selects a coffee -- after login succeeded | |
coffeeButton = phoneWait.until(ExpectedConditions.elementToBeClickable(mobileApp.menuScreen.coffeeButton)); | |
coffeeButton.click(); | |
// API finds the customer order and sets it to out of stock | |
order = baristaApi.findOrdersForCustomer(customer.username).get(0); | |
baristaApi.markOrderAsOutOfStock(order); | |
// Customer is prompted to cancel or place new order | |
orderConfirmationDialog = phoneWait.until(ExpectedConditions.visibilityOfElementLocated(mobileApp.orderConfirmationDialog)); | |
// User receives out of stock notification and can cancel or place new order | |
assertThat(orderConfirmationDialog.getText()).contains("Out of Stock"); | |
assertThat(orderConfirmationDialog.findElement(By.accessibilityId("Cancel Order"))).exists(); | |
assertThat(orderConfirmationDialog.findElement(By.accessibilityId("Place New Order"))).exists(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment