Skip to content

Instantly share code, notes, and snippets.

@Jaimin180296
Created June 8, 2021 10:52
Show Gist options
  • Save Jaimin180296/abd8fc51a5f9de67068d7e062f3e4206 to your computer and use it in GitHub Desktop.
Save Jaimin180296/abd8fc51a5f9de67068d7e062f3e4206 to your computer and use it in GitHub Desktop.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
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;
import java.util.concurrent.TimeUnit;
public class SafariDriver {
public static final String AUTOMATE_USERNAME = "<username>";
public static final String AUTOMATE_ACCESS_KEY = "<acesskey>";
public static final String URL = "http://" + AUTOMATE_USERNAME + ":" + AUTOMATE_ACCESS_KEY + "@hub-cloud.browserstack.com/wd/hub";
static WebDriver driver;
@Test
public void setup() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("os_version", "13");
caps.setCapability("device", "iPhone XS");
caps.setCapability("real_mobile", "true");
caps.setCapability("build", "Ticket#437054");
caps.setCapability("browserstack.appium_version", "1.20.2");
driver = new RemoteWebDriver(new URL(URL), caps);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://visitscotland.org/");
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[@data-test='open-modal']"))).click();
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment