Hi, I am getting started on automation using Appium java client, and have been trying to test our iOS application and have been running into a profile.
We have a screen that implements the UIATableView and from what I can see it has three field (Cells), which is supposed to hold the configuration of a server where the user has to connect. Server, Port, and Tenant.
When the screen is just loaded, the source code looks like this:
<UIATableView name="" label="" value="rows 1 to 3 of 3" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1" x="0" y="64" width="320" height="272">
<UIATableCell name="Server Address" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0" x="0" y="64" width="320" height="62">
<UIAStaticText name="Server Address" label="Server Address" value="Server Address" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0/0" x="15" y="74" width="290" height="17">
</UIAStaticText>
</UIATableCell>
<UIATableCell name="Server Port" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1" x="0" y="126" width="320" height="62">
<UIAStaticText name="Server Port" label="Server Port" value="Server Port" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/0" x="15" y="136" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="80" label="80" value="80" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/1" x="15" y="151" width="290" height="25">
</UIAStaticText>
</UIATableCell>
<UIATableCell name="Tenant ID" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2" x="0" y="188" width="320" height="62">
<UIAStaticText name="Tenant ID" label="Tenant ID" value="Tenant ID" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/0" x="15" y="198" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="infor" label="infor" value="infor" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/1" x="15" y="213" width="290" height="25">
</UIAStaticText>
</UIATableCell>
</UIATableView>
After I click on the first field (Server Address), I can see that two new fields are added under the cell:
<UIATableView name="" label="" value="rows 1 to 3 of 3" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1" x="0" y="64" width="320" height="272">
<UIATableCell name="Server Address" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0" x="0" y="64" width="320" height="67">
<UIAStaticText name="Server Address" label="Server Address" value="Server Address" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0/0" x="15" y="74" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="Server Address" label="Server Address" value="Server Address" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0/1" x="15" y="74" width="290" height="17">
</UIAStaticText>
<UIATextField name="" label="" value="" dom="" enabled="true" valid="true" visible="false" hint="" path="/0/0/1/0/2" x="15" y="89" width="275" height="30">
<UIATextField name="" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0/2/0" x="15" y="89" width="275" height="30">
</UIATextField>
</UIATextField>
</UIATableCell>
<UIATableCell name="Server Port" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1" x="0" y="131" width="320" height="62">
<UIAStaticText name="Server Port" label="Server Port" value="Server Port" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/0" x="15" y="141" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="80" label="80" value="80" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/1" x="15" y="156" width="290" height="25">
</UIAStaticText>
</UIATableCell>
<UIATableCell name="Tenant ID" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2" x="0" y="193" width="320" height="62">
<UIAStaticText name="Tenant ID" label="Tenant ID" value="Tenant ID" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/0" x="15" y="203" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="infor" label="infor" value="infor" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/1" x="15" y="218" width="290" height="25">
</UIAStaticText>
</UIATableCell>
</UIATableView>
After I enter a value on the cell, it becomes:
<UIATableView name="" label="" value="rows 1 to 3 of 3" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1" x="0" y="64" width="320" height="272">
<UIATableCell name="Server Address" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0" x="0" y="64" width="320" height="62">
<UIAStaticText name="Server Address" label="Server Address" value="Server Address" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0/0" x="15" y="74" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="https:://acme.mobile.com" label="https:://acme.mobile.com" value="https:://acme.mobile.com" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/0/1" x="15" y="89" width="290" height="25">
</UIAStaticText>
</UIATableCell>
<UIATableCell name="Server Port" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1" x="0" y="126" width="320" height="67">
<UIAStaticText name="Server Port" label="Server Port" value="Server Port" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/0" x="15" y="136" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="443" label="443" value="443" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/1/1" x="15" y="151" width="290" height="25">
</UIAStaticText>
</UIATableCell>
<UIATableCell name="Tenant ID" label="" value="" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2" x="0" y="193" width="320" height="67">
<UIAStaticText name="Tenant ID" label="Tenant ID" value="Tenant ID" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/0" x="15" y="203" width="290" height="17">
</UIAStaticText>
<UIAStaticText name="Tenant ID" label="Tenant ID" value="Tenant ID" dom="" enabled="true" valid="true" visible="true" hint="" path="/0/0/1/2/1" x="15" y="203" width="290" height="17">
</UIAStaticText>
</UIATableCell>
</UIATableView>
I was able to find this information using the Appium Inspector.
In my script, I am able to locate the table and retrieve the 3 cells in it. However when I start iterating through the cells and try to set the value for the first field (Server Address) , it shows it for a second util the next iteration when the focus moves to the next cell (Server Port). At that point the value is cleaned, and I get a warning that the Server Address is a required field. Then next I get an error that the cannot set a value for the Server Port, which apparently is being defined as a Static Text Field.
WebElement table = driver.findElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]");
List<WebElement> cells = table.findElements(By.className("UIATableCell"));
for (int i = 0; i < cells.size(); i++) {
IOSElement curCell = (IOSElement) cells.get(i);
String attrName = curCell.getAttribute("name");
curCell.click();
if (attrName.equals("Server Address")) {
serverName = curCell;
serverName.setValue("https://myapp.acme.com");
}
if (attrName.equals("Server Port")) {
portNumber = curCell;
portNumber.setValue("443");
}
if (attrName.equals("Tenant ID")) {
tenant = curCell;
tenant.setValue("acme_prd");
}
}