I'm trying to create automation E2E testing for an SDK we build. We decided to test the SDK with a test app that will call the commands in a table that will test all SDK capabilities.
I was stuck for a while, Not understanding why some click events are working and some are not.
I've figure this out, It is because the ones that are working are visible and the the ones that are not working are not visible (don't really exists until the cell is created when needed to be visible?). In any case this is what I think or Hoping for because if not i really don't understand what is going on.
Example for code that is working:
@Test
public void step2_resetToken() throws InterruptedException {
int count = 0;
String s;
do {
MobileElement mElement = (MobileElement) iosDriver.findElement(By.name("Reset Token"));
mElement.click();
Thread.sleep(500);
count++;
assert count < TIMEOUTTIME;
s = element.getText();
System.out.println(s);
} while(!(element.getText().contains("reset token performed:")));
}
Example for code that is not working:
@Test
public void step3_isAuthenticatedByPIN() throws InterruptedException {
WebElement tableView = (WebElement) iosDriver.findElementByClassName("XCUIElementTypeTable");
tableView.scrollTo("isAuthenticatedByPIN").click();
int count = 0;
String s;
do {
////XCUIElementTypeStaticText[@name="isAuthenticatedByPIN"]
MobileElement mElement = (MobileElement) iosDriver.findElementByClassName("XCUIElementTypeTable");
mElement.sendKeys("isAuthenticatedByPIN");
mElement.findElement(By.name("isAuthenticatedByPIN"));
mElement.click();
Thread.sleep(500);
count++;
assert count < TIMEOUTTIME;
s = element.getText();
System.out.println(s);
} while(!(element.getText().contains("isAuthenticatedByPIN: YES")));
}
I've tried also calling this method before so there will be a scroll but it seems that it just can't find elements that where not visible when the app started:
public static void scrolltoXPath(RemoteWebDriver driver, String xPath) {
RemoteWebElement parent = (RemoteWebElement)driver.findElement(By.className("XCUIElementTypeTable"));
String parentID = parent.getId();
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("element", parentID);
scrollObject.put("name", "isConnected");
driver.executeScript("mobile:scroll", scrollObject);
}
This what a tests to try with scrollTo but Java-client does not recognise scrollTo (Is this Java or Javascript method). Also i've tried with all other methods i found in google and couldn't figure this out.
- Anyone can tell me if i'm right about the conclusion that i cant click on a cell that is not displayed?
- If so, Please help with how to scroll to the cell i need to click on.
Thanks.