Created
March 31, 2021 18:25
-
-
Save Jaimin180296/94f4a55538572a23f9d1d93a58db1eff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import io.appium.java_client.MobileBy; | |
import io.appium.java_client.android.AndroidDriver; | |
import io.appium.java_client.android.AndroidElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.support.ui.ExpectedConditions; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
import org.testng.annotations.Test; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
public class AndroidApp { | |
@Test | |
public void setup() throws MalformedURLException, InterruptedException { | |
DesiredCapabilities caps = new DesiredCapabilities(); | |
caps.setCapability("browserstack.user", "<username>"); | |
caps.setCapability("browserstack.key", "<accesskey>"); | |
caps.setCapability("os_version", "10.0"); | |
caps.setCapability("device", "Samsung Galaxy S20 Ultra"); | |
caps.setCapability("real_mobile", "true"); | |
caps.setCapability("browserstack.local", "false"); | |
caps.setCapability("app", "<app_url>"); | |
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>( | |
new URL("http://hub.browserstack.com/wd/hub"), caps); | |
// Test case for the BrowserStack sample Android app. | |
// If you have uploaded your app, update the test case here. | |
AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until( | |
ExpectedConditions.elementToBeClickable( | |
MobileBy.id("com.marketyo.platform:id/iv_arrowUp"))); | |
searchElement.click(); | |
Thread.sleep(5000); | |
// Invoke driver.quit() after the test is done to indicate that the test is completed. | |
driver.quit(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment