UI testing Xcode 7, How to get access to element in collectionview - ios

I have an collectionview with invested ellements inside. The objects coming as images. So the problem is taping on these elements. I can`t pick elements from this window, and Accessibility Inspector showing my whole window with elements as button with missing accessibility values.
Image of Accessibility Inspector
So, if I am using just Record button, then I am getting this code, but it doesn`t work to play. I still have no lables and indexes.
XCUIApplication().childrenMatchingType(.Window).elementBoundByIndex(0).childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Other).element.childrenMatchingType(.Button).element.tap()
Does anyone know, how to solve this problem?

Try to access control in following manner (better to debug and check value of each element in progressive manner using po)
[XCUIApplication.buttons elementBoundbyIndex:0]
Or
[[[XCUIApplication.windows elementBoundbyIndex:0] buttons] elementBoundbyIndex:0] ... so on.

Related

Android Unable to identify elements in Appium inspector instead of one element whole panel type of area is selecting

This is image of android inspectorUnable to identify elements in Appium inspector instead of one element whole panel type of area is selecting when I click on menu I want to select on element from that menu which comes from left to right.
Please help me so that I can find a single element's xpath right now whole panel is getting selected in appium inspector. enter image description here this is on android.
Unfortunately it's not behaviour you can change in the Appium Inspector.
That doesn't mean it stops you from identifying elements. You can click on the XML tree and open and look manually for your elements. If you found the right element in the tree, then you can check out the properties and work out the right XPath.
After that you can test the XPath by using the selector tester in the top menu of the Inspector.
New edit:
Automating between Native and WebView can be read here on appium.io. The elements you find in the inspector are probably in the WebView and you must switch to this in order for Appium to reach the correct elements.
Step 1: Print out all possible views through - this way you can retrieve what views there are and switch between them if you are in the app. Within hybrid apps, there are different views and you need to enter the correct one first in order to automate elements.
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextNames); //prints out something like NATIVE_APP \n WEBVIEW_1
}
driver.context(contextNames.toArray()[INDEX]);
Step 2: Print the page source to get a scope of all elements in the currenct view through driver.getPageSource(). If you do this for all views you can see the possibilities and elements you have.

Storyboard element locations are off

I am currently building a project using storyboards and am having an issue when trying to select elements. When I try and click on an element, it selects the element a bit under it, and to select a certain element I have to aim above it. I have disabled the adjustment of scroll view insets, so I am not sure as to why this is happening. I've attached some demonstration photos. Any help is appreciated, Thanks!
Here I am selecting the "Like" Button:
And here I am selecting the image of a palm tree:

UI Testing Multiple UITextFields

I'm trying to create a UITest using the recording function for an app that contains multiple UITextFields per view. When trying to do so I'm having a couple issues.
To simplify the issue I have created an application with two text fields nested inside one subview as shown in the picture.
From here I opened the identity inspector and changed the label of the two UITextFields under the accessibility heading to 'topField' and 'bottomField' (accessibility disabled on the gray UIView). Then I went into the UITest 'testExample' function and click the record button. From here I click the top text field, type something in, then when I click the bottom text field I get this error 'Timestamped Event Matching Error: Failed to find matching element'.
What am I missing here? I know this is a result of Xcode not being able to find the text field in the hierarchy, but I don't know why since I have given labels to each element in accessibility. I am able to manually write the code into the testing method to access the second text field without any errors, but the recording is not working. Any help is greatly appreciated.

Appium doesn't update it's view in list element and subelements

I am working on iOS native app and when trying to read from tableView/tableCells I have a problem getting the updated values. At the first time i enter the page/screen I can see all cells. But , if i create an action that adds another cell to the table view when I try to get the list of cells I see an empty list.
Also, When i change a subelement in that cell I can't see the changed sub element both in inspector and in the code.
I tried switching to a different page and also changing tabs in that page and reread the table/cell and subelements but it didn't help.
I've had this issue before. There is no actual reload elements kind of function that I've seen. However a workaround I've found that works is to simply find an element that exists and it'll reload the elements after it does that.
For example:
yourMethodThatLoadsNewElements();
driver.findElementBy(pathToElementThatExistedBefore);
driver.findElementBy(pathToElementThatWasJustLoaded);

Where is the combobox object in interface builder?

I just updated to Xcode 5.0.2 and in interface builder on the lower right corner where I can drag and drop objects I don't see combobox any more. I tried using the search field below and typed combobox, NSCombobox, but nothing.
Using a UIPickerView will probably get you far
It's easy to make a ComboBox lookalike. It consists of only three parts in InterfaceBuilder xib:
A Label for holding the selected choice. I've made it with a white background to look like an input field.
A graphic Button with an arrow
A ListView
The ListView is normally invisible (setHidden:TRUE) and is placed over other items in this xib.
A tap on the Button makes the ListView visible (setHidden:FALSE).
At selection, didSelectRowAtIndexPath writes the selected string to the label and set ListView hidden.
Combo boxes are available only for Mac projects, not iOS projects, so you're getting the expected behavior. If you create a Cocoa application project and type combo in the object library's search field, the combo box and combo box cell objects should appear in the object library.
I'm surprised you were able to access a combo box in earlier versions of Xcode. I don't remember combo boxes ever being available in iOS projects.
I also needed a HTML select-like control (single-selection dropdown list) without breaking the XCode legacy GUI interface across past and future iOS releases.
I ended up coding DownPicker, a lightweight control which does just that combining UITextField and UIPickerView. It can be used either as custom control (UIDownPicker) or also as control wrapper, upgrading any existing UITextField.
Here's how it looks like:
For more info and download you can check this brief tutorial or the GitHub project page (both made by me - the project is open-source).

Resources