The issue goes on with "XCUIElementTypeAlert". It works for ipad but not for iphone.
My page source is
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
/**
* Created by appium on 13/3/17.
*/
public class appiumTest {
//private RemoteWebDriver driver;
// public AppiumDriver<MobileElement> driver;
private AppiumDriver<WebElement> driver;
private List<Integer> values;
public WebDriverWait wait ;
@Before
public void setup() throws MalformedURLException{
DesiredCapabilities desiredCapabilities;
desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName","IPad Air2");
//desiredCapabilities.setCapability("deviceName","iPhone 5s");
desiredCapabilities.setCapability("udid","07436359a6f86dce57b77a0b941b92d6975e3480");
//desiredCapabilities.setCapability("udid","2E611BE3-7495-4BFE-A288-EB24BFC828CC");
desiredCapabilities.setCapability("platformVersion","10.2.1");
desiredCapabilities.setCapability("appiumVersion","v1.6.0");
desiredCapabilities.setCapability("platformName","iOS");
//desiredCapabilities.setCapability("orientation","LANDSCAPE");
desiredCapabilities.setCapability("automationName","XCUITest");
desiredCapabilities.setCapability("xcodeOrgId","DXKN9UUK5Q");
desiredCapabilities.setCapability("xcodeSigningId","iPhone Developer");
//desiredCapabilities.setCapability("automationName","UIautomation");
//requiredcapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.iOS);
//requiredcapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Ipad Air2 Device");
desiredCapabilities.setCapability("app","/Users/appium/Documents/PruebaAppium_old.ipa");
desiredCapabilities.setCapability("realDeviceLogger","/usr/local/lib/node_modules/deviceconsole/deviceconsole");
//driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"),desiredCapabilities);
driver = new IOSDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),desiredCapabilities);
//driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),desiredCapabilities){};
wait=new WebDriverWait(driver,60);
}
@After
public void tearDown() throws Exception{
driver.quit();
}
@Test
public void selectLoginWithEmail() {
List<WebElement> elems = driver.findElements(By.className("UIATextField"));
for (WebElement elem : elems) {
elem.sendKeys("trytryte");
}
//WebElement cajaCorreo = driver.findElement(By.name("Email"));
WebElement cajaCorreo = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]"));
cajaCorreo.sendKeys("correo");
WebElement button = driver.findElement(By.className("UIAButton"));
button.click();
//WebElement texto =driver.findElement(By.className("UIAAlert"));
WebElement texto = driver.findElement(By.className("XCUIElementTypeAlert"));
String texto2 = texto.getAttribute("label");
System.out.print(texto2);
Assert.assertTrue("Correcto",texto2.equalsIgnoreCase("Login KO"));
//try {
// Thread.sleep(55000);
//} catch (InterruptedException e) {
//}
}
}
An the error message Amazon returns is:
selectLoginWithEmail failed: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 910 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'ip-172-31-13-65', ip: '172.31.13.65', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-53-generic', java.version: '1.8.0_65' Driver info: io.appium.java_client.ios.IOSDriver Capabilities [{app=com.ibermatica.PruebaAppium, networkConnectionEnabled=false, appiumVersion=v1.6.0, xcodeOrgId=DXKN9UUK5Q, databaseEnabled=false, deviceName=IPad Air2, xcodeSigningId=iPhone Developer, platform=MAC, realDeviceLogger=/usr/local/lib/node_modules/deviceconsole/deviceconsole, platformVersion=10.2.1, webStorageEnabled=false, locationContextEnabled=false, browserName=, takesScreenshot=true, javascriptEnabled=true, platformName=iOS, udid=278d7a1371d7a4fc9e2eb0b4639c70969e0eaaa3}] Session ID: 55054aef-5092-4d0a-a77b-8c0eb3ae2205 *** Element info: {Using=class name, value=XCUIElementTypeAlert}
Any help would be appreciated.