@@ -16,36 +16,30 @@ public class BrowserStackIOS {
16
16
public static String userName = "BROWSERSTACK_ACCESS_KEY" ;
17
17
18
18
public static void main (String args []) throws MalformedURLException , InterruptedException {
19
- DesiredCapabilities capabilities = new DesiredCapabilities ();
19
+ DesiredCapabilities caps = new DesiredCapabilities ();
20
20
21
- capabilities .setCapability ("device" , "iPhone 7" );
22
- capabilities .setCapability ("app" , "bs://<hashed app-id>" );
21
+ caps .setCapability ("device" , "iPhone 7 Plus " );
22
+ caps .setCapability ("app" , "bs://<hashed app-id>" );
23
23
24
- IOSDriver <IOSElement > driver = new IOSDriver <IOSElement >(new URL ("http://" +userName +":" +accessKey +"@hub.browserstack.com/wd/hub" ), capabilities );
24
+ IOSDriver <IOSElement > driver = new IOSDriver <IOSElement >(new URL ("http://" +userName +":" +accessKey +"@hub-cloud .browserstack.com/wd/hub" ), caps );
25
25
26
- IOSElement loginButton = (IOSElement ) new WebDriverWait (driver , 30 ).until (
27
- ExpectedConditions .elementToBeClickable (MobileBy .AccessibilityId ("Log In " )));
28
- loginButton .click ();
29
- IOSElement emailTextField = (IOSElement ) new WebDriverWait (driver , 30 ).until (
30
- ExpectedConditions .elementToBeClickable (MobileBy .AccessibilityId ("Email address " )));
31
- emailTextField .sendKeys ("hello@browserstack.com" );
26
+ IOSElement textButton = (IOSElement ) new WebDriverWait (driver , 30 ).until (
27
+ ExpectedConditions .elementToBeClickable (MobileBy .AccessibilityId ("Text Button " )));
28
+ textButton .click ();
29
+ IOSElement textInput = (IOSElement ) new WebDriverWait (driver , 30 ).until (
30
+ ExpectedConditions .elementToBeClickable (MobileBy .AccessibilityId ("Text Input " )));
31
+ textInput .sendKeys ("hello@browserstack.com" );
32
32
33
- driver .findElementByAccessibilityId ("Next" ).click ();
34
33
Thread .sleep (5000 );
35
34
36
- List <IOSElement > textElements = driver .findElementsByXPath ("//XCUIElementTypeStaticText" );
37
- assert (textElements .size () > 0 );
38
- String matchedString = "" ;
39
- for (IOSElement textElement : textElements ) {
40
- String textContent = textElement .getText ();
41
- if (textContent != null && textContent .contains ("not registered" )) {
42
- matchedString = textContent ;
43
- }
44
- }
45
-
46
- System .out .println (matchedString );
47
- assert (matchedString .contains ("not registered on WordPress.com" ));
48
-
35
+ IOSElement textOutput = (IOSElement ) new WebDriverWait (driver , 30 ).until (
36
+ ExpectedConditions .elementToBeClickable (MobileBy .AccessibilityId ("Text Output" )));
37
+
38
+ if (textOutput != null && textOutput .getText ().equals ("hello@browserstack.com" ))
39
+ assert (true );
40
+ else
41
+ assert (false );
42
+
49
43
driver .quit ();
50
44
}
51
45
}
0 commit comments