Skip to content

Changes for new sample app #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2018
Merged
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
42 changes: 18 additions & 24 deletions ios/BrowserStackIOS.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,30 @@ public class BrowserStackIOS {
public static String userName = "BROWSERSTACK_ACCESS_KEY";

public static void main(String args[]) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
DesiredCapabilities caps = new DesiredCapabilities();

capabilities.setCapability("device", "iPhone 7");
capabilities.setCapability("app", "bs://<hashed app-id>");
caps.setCapability("device", "iPhone 7 Plus");
caps.setCapability("app", "bs://<hashed app-id>");

IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(new URL("http://"+userName+":"+accessKey+"@hub.browserstack.com/wd/hub"), capabilities);
IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(new URL("http://"+userName+":"+accessKey+"@hub-cloud.browserstack.com/wd/hub"), caps);

IOSElement loginButton = (IOSElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Log In")));
loginButton.click();
IOSElement emailTextField = (IOSElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Email address")));
emailTextField.sendKeys("[email protected]");
IOSElement textButton = (IOSElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Button")));
textButton.click();
IOSElement textInput = (IOSElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Input")));
textInput.sendKeys("[email protected]");

driver.findElementByAccessibilityId("Next").click();
Thread.sleep(5000);

List<IOSElement> textElements = driver.findElementsByXPath("//XCUIElementTypeStaticText");
assert(textElements.size() > 0);
String matchedString = "";
for(IOSElement textElement : textElements) {
String textContent = textElement.getText();
if(textContent != null && textContent.contains("not registered")) {
matchedString = textContent;
}
}

System.out.println(matchedString);
assert(matchedString.contains("not registered on WordPress.com"));

IOSElement textOutput = (IOSElement) new WebDriverWait(driver, 30).until(
ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Text Output")));

if(textOutput != null && textOutput.getText().equals("[email protected]"))
assert(true);
else
assert(false);

driver.quit();
}
}
2 changes: 1 addition & 1 deletion ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
curl -u "username:accesskey" -X POST "https://api.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/Application-debug.ipa"
```

- If you do not have an .ipa file and looking to simply try App Automate, [you can download our sample app and upload](https://www.browserstack.com/app-automate/sample-apps/ios/WordPressSample.ipa)
- If you do not have an .ipa file and looking to simply try App Automate, [you can download our sample app and upload](https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa)
to the BrowserStack servers using the above API.
- Update the desired capability "app" with the App URL returned from the above API call

Expand Down