package sample.Seetest;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.MobileBrowserType;
import org.testng.annotations.*;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.Keys;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Set;
public class LocaliOSTest {
private String accessKey = "eyJ4cC51Ijo3NTgzMzczLCJ4cC5wIjo3NTgzMzcyLCJ4cC5tIjoiTVRVM01UYzFNakEyTkRJd05BIiwiYWxnIjoiSFMyNTYifQ.eyJleHAiOjE4ODcxMTIwOTAsImlzcyI6ImNvbS5leHBlcml0ZXN0In0.R47MeNXeUeRGukUeRnBMQxiwjjgwVl-XYhv2PlMrrZ0";
protected IOSDriver<IOSElement> driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
@BeforeTest
public void setUp() throws MalformedURLException {
dc.setCapability("testName", "SHIVA Quick Start iOS Browser Demo ");
dc.setCapability("accessKey", accessKey);
dc.setCapability("deviceQuery", "@os='ios' and @category='PHONE'");
dc.setBrowserName(MobileBrowserType.SAFARI);
dc.setCapability("cleanSession","true");
dc.setCapability("ensureCleanSession","true");
driver = new IOSDriver<>(new URL("https://cloud.seetest.io/wd/hub"), dc);
}
@Test
public void quickStartiOSBrowserDemo() {
driver.get("https://www.autozone.com/");
Set<Cookie> cookies = driver.manage().getCookies();
System.out.println("Cookies size "+cookies.size());
Iterator<Cookie> itr = cookies.iterator();
while (itr.hasNext()){
Cookie c = itr.next();
System.out.println("Cookies name "+c.getName());
driver.manage().deleteCookie(c);
System.out.println("Deleted Cookies name "+c.getName());
}
driver.rotate(ScreenOrientation.PORTRAIT);
// new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='siteLogo']")));
//driver.findElement(By.xpath("//*[@id='siteLogo']")).click();
//new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("(//*[@value='Log In'])[1]")));
}
@AfterTest
public void tearDown() {
System.out.println("Report URL: "+ driver.getCapabilities().getCapability("reportUrl"));
driver.quit();
}
}