Last active
June 25, 2016 11:52
-
-
Save pr4bh4sh/d1274e0efac73e176b7b to your computer and use it in GitHub Desktop.
This file contains 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.AppiumDriver; | |
import io.appium.java_client.ios.IOSDriver; | |
import io.appium.java_client.remote.MobileBrowserType; | |
import io.appium.java_client.remote.MobileCapabilityType; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.testng.annotations.AfterClass; | |
import org.testng.annotations.BeforeClass; | |
import org.testng.annotations.Test; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
public class SafariTest | |
{ | |
AppiumDriver<WebElement> driver; | |
@BeforeClass | |
public void setUp() throws MalformedURLException | |
{ | |
DesiredCapabilities capabilities = new DesiredCapabilities(); | |
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.SAFARI); | |
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS"); | |
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 5s"); | |
capabilities.setCapability("udid", UDID); | |
driver = new IOSDriver<WebElement>(new URL("http://localhost:4723/wd/hub"), capabilities); | |
} | |
@AfterClass | |
public void tearDown() | |
{ | |
driver.quit(); | |
} | |
@Test | |
public void test() throws InterruptedException | |
{ | |
System.out.println("in test"); | |
Thread.sleep(10000);// give time to load the webview | |
System.out.println("wait finished"); | |
for (String context : driver.getContextHandles()) | |
{ | |
System.out.println(context); | |
if (context.toLowerCase().contains("web")) | |
driver.context(context); | |
} | |
System.out.println("context finished"); | |
driver.get("http://google.com"); | |
driver.findElement(By.name("q")).sendKeys("hello\n"); | |
Thread.sleep(5000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the .java extension to the file.