Skip to content

Update BrowserStackSample.java #27

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
36 changes: 7 additions & 29 deletions java_7/src/test/java/ios/BrowserStackSample.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
package ios;

import java.net.URL;
import java.util.List;
import java.net.MalformedURLException;

import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;

import io.appium.java_client.MobileBy;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;

public class BrowserStackSample {

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

// Set your access credentials
caps.setCapability("browserstack.user", "YOUR_USERNAME");
caps.setCapability("browserstack.key", "YOUR_ACCESS_KEY");
caps.setCapability("browserstack.user", "abdullazizxs_M0W5GX");
caps.setCapability("browserstack.key", "zS2Tit6YTbuhoCGgbB21");

// Set URL of the application under test
caps.setCapability("app", "bs://<app-id>");
caps.setCapability("app", "bs://ff266c82636fc47ee3a615747bc9a7b63857a03d");

// Specify device and os_version for testing
caps.setCapability("device", "iPhone 12");
caps.setCapability("os_version", "13");
caps.setCapability("device", "iPhone XS");
caps.setCapability("os_version", "12");

// Set other BrowserStack capabilities
caps.setCapability("project", "First Java Project");
Expand All @@ -38,27 +33,10 @@ public static void main(String[] args) throws MalformedURLException, Interrupted
// and desired capabilities defined above
IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(
new URL("http://hub-cloud.browserstack.com/wd/hub"), caps);

// Write your test case statements here


// Test case for the BrowserStack sample iOS app.
// If you have uploaded your app, update the test case here.
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]");
Thread.sleep(5000);
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);

// Invoke driver.quit() after the test is done to indicate that the test is completed.
driver.quit();

}

}