package iosPOC;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import io.appium.java_client.ios.IOSDriver;
import java.net.URL;
public class SafariTest {
private WebDriver driver;
@BeforeTest
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "iPhone 6");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "10.2");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("browserName", "safari");
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
// driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void runTest() throws Exception {
driver.get("URL");
Thread.sleep(1000);
WebElement idElement = driver.findElement(By.id("i_am_an_id"));
assertNotNull(idElement);
assertEquals("I am a div", idElement.getText());
WebElement commentElement = driver.findElement(By.id("comments"));
assertNotNull(commentElement);
commentElement.sendKeys("This is an awesome comment");
WebElement submitElement = driver.findElement(By.id("submit"));
assertNotNull(submitElement);
submitElement.click();
Thread.sleep(7000);
WebElement yourCommentsElement = driver.findElement(By.id("your_comments"));
assertNotNull(yourCommentsElement);
assertTrue(driver.findElement(By.id("your_comments")).getText().contains("This is an awesome comment"));
System.out.println(driver.getCurrentUrl());
}
@AfterTest
public void tearDown() throws Exception {
driver.quit();
}
}