UI Testing Multiple UITextFields - ios

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.

Related

FloatingLabel Text Filed place holder animation issues while using JVFloatLabeledTextField

I wanted a floating label text filed with underline or baseline for one of my iOS apps. I found that I can achieve that by making use of JVFloatLabeledTextField. So I drag & dropped some text fields to my storyboard and assigned JVFloatLabeledTextField as a class(custom) to those fields so that these text fields will be of type JVFloatLabeledTextField.
ISSUE1
In the below image the first part is what is showed after running the app. The issue here is when I start typing text in any of the textFields the place holder should animate upward but in my case the place holder is not showed/disappears as shown in the 2nd part of below image.When we tap on any other textField then the previously used textField palce holder is showed as shown in 3rd part of below image.
ISSUE2
keepBaseline = true, I have given this property to get the underline/baseline for the textFields, which I'm not getting.
I'm keeping all these text Fields in a stack view, will that cause any issue?
Programatically I haven't written any code for this.
Find the image here

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

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.

How to test UITextField in Xcode UI Testing when the text field is empty?

I am making a UITest in Xcode. When I record my test it works fine but when I run the test, it gives an error.
These are the lines of code where the error occurs:
XCUIElement *clearTextTextField = [app.textFields containingType:XCUIElementTypeButton
identifier:#"Clear text"].element;
[clearTextTextField typeText:#"sheffield"];
The error says
UI Testing Failure - No matches found for textfield
I imagine this is because my Text Field does not have any initial string and the tester cannot find a text box with initial string "Clear Text".
I watched the following tutorial on youtube.
The demonstrators code turns out fine because his textfield has an initial string. (At least that is what I think the problem is)
Is there a way to make the test work for empty text fields?
There are a few ways to do this.
If the textField has placeholder text you can use the placeholder text to find the textField.
You can use the elementBoundByIndex method to get a textField at an index. i.e. If that is the only textField in the app at the time you can use
XCUIApplication().textFields.elementBoundByIndex(0)
to get the textField. (or whatever query you need to get that particular textField at that time)
You can set an accessibility identifier in code or in the storyboard to find the textField.
It is nice to use option 2 before setting up accessibility identifiers, so long as your textField is always going to be findable with the same query. Also, option 1 will fail if multiple textFields have the same placeholder text at the same time, so option 2 is even more appealing.

Can't find field to check or set UIButton tag--Xcode 5.0

I've got a number of buttons in a view and have assigned a tag number to each for identification in code. I just went back to check one of them, and can't find the field in the Attributes Inspector where I originally assigned the tags. I've tried all my buttons and restarted Xcode, and the result is the same--no tag field.
Here's what my attribute inspector looks like with a (tagged) button selected in the storyboard:
I came upon a recent comment by someone who also couldn't locate the tag field. He also is using Xcode 5.0.2.
Anybody else run into this?
Thanks!
The sections in the attributes inspector can be shown or hidden by clicking on the lines where the words "View", "Control", etc appear. When you rollover the line with these section titles, you'll see the words "show" or "hide" appear on the right edge of the line. Clicking anywhere on the line toggles between the two states.
Where it says view: Move your mouse over to the far right and something should appear that says "Show". Click on it and you'll see the tag identifiers, etc.

Coded UI Test Builder assertions cannot access to DOM

I'm tring to make come UI test using Coded UI. Unfortuanley, It seems to not have access to all DOM elements in browser.
I want to assert value of one text block in form, and by"Add Assertion" the lowest element i can assert is form itself. All tags contained by form was flatten and putted to "id" property in "Add Assertion" widnows, like in the screen below:
Is there a way to assert only one tag in form? In this case i want to assert value "Szczegóły przesyłki: 0--1526203258"
It depends on how your web page is designed. From the image shown it it not clear what field contains the Szczegóły przesyłki: 0--1526203258. However, given (1) the scroll bar and (2) that the Id field is shown and is empty, it is probably the Inner Text field.
Given the number of lines shown above and below the required text you are likely to have selected a larger than necessary part of the screen. When creating an assertion is it often best to move the cross hairs tool around the screen to find the smallest control that contains the required field. Such a UI Control will have no child controls.
I have found that occasionally the Coded UI cross hairs tool loses its place and leaves all four (UP, DOWN, LEFT and RIGHT) arrows grey and inactive, as shown in the screenshot. When this happens try clicking the refresh button located between Add Assertion and the arrows. Some of the arrows should then be shown as black and active. If the DOWN arrow is grey (inactive) and some of the other arrows are black then the properties panel shows a UI Control that has no child components. You should be able to find a UI Control that contains only the required text.

Resources