diff --git a/ios/BrowserStackIOS.java b/ios/BrowserStackIOS.java index 250e007..48b2799 100644 --- a/ios/BrowserStackIOS.java +++ b/ios/BrowserStackIOS.java @@ -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://"); + caps.setCapability("device", "iPhone 7 Plus"); + caps.setCapability("app", "bs://"); - IOSDriver driver = new IOSDriver(new URL("http://"+userName+":"+accessKey+"@hub.browserstack.com/wd/hub"), capabilities); + IOSDriver driver = new IOSDriver(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("hello@browserstack.com"); + 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("hello@browserstack.com"); - driver.findElementByAccessibilityId("Next").click(); Thread.sleep(5000); - List 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("hello@browserstack.com")) + assert(true); + else + assert(false); + driver.quit(); } } diff --git a/ios/README.md b/ios/README.md index 7124353..91485a6 100644 --- a/ios/README.md +++ b/ios/README.md @@ -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