Why is the same code in G1ANT showing different results in different iterations? - g1ant

For example, let there be statements like :-
Keyboard variable1
keyboard enter
Keyboard variable2
keyboard enter
.
.
.
.
.
In such cases, in some iterations it will be correctly entered, however in some iterations the two keyboard commands will run one after the other, then the middle enter command will run, this results in loss of characters in the stream.

It can be caused by the application/system response time, try to add a 'delay' before Enter. You can also experiment with 'keydelay' in the keyboard command.
keyboard keydelay 50 text ♥test

Related

XCode: Use decimal pad that ALWAYS displays dot '.' and not comma ','

I am new to Swift and this is my first application. I essentially want a user to enter two numbers, that I can use for some calculations. For the text fields I used the option "Decimal Pad" as keyboard type. With the simulator it works well - on my phone, however, the dot is shown as a comma, which causes the app to crash. Is there an easy fix for this problem? I don't want any global changes for the location or the keyboards used, but just a fixed decimal pad with dot instead of comma.
Thank you!

XCUITest: Failed to find Matching Element

I have a close button on a ViewController that is being presented as a ChildViewController. I have this button's accessibility turned on and the accessibility identifier is closeButton. This button does not have any text, it just has an image.
I am attempting to test the presentation and dismissal of this view, but am running into an issue, the XCUITest cannot find the element. My test code is:
app.buttons["PresentChild"].tap()
XCTAssertTrue(app.otherElements["ChildViewController"].exists)
XCTAssertTrue(app.buttons["closeButton"].exists)
The first assert passes, but the second assert fails.
I tried to do the "Record UI Test" to select the button to have it be automatically generated, but then I just get an error saying Failed to find Matching Element. I tried erasing all the content on the simulator and deleting all derived data, and that didn't work either.
Does anyone know a workaround to this obvious bug in Xcode? I can't access the element through the recording, I can't access the element through the accessibility feature, I have zero idea how else to access this button.
I don't know what is the exact problem with your assertion. But this steps may help you.
Put a breakpoint on this line XCTAssertTrue(app.otherElements["ChildViewController"].exists)
Now run the test case. When the control reaches this line, type this line in the debugger po XCUIApplication().buttons.debugDescription then tap the enter button
It will print all buttons in your current view. Now check whether the "closeButton" exists in that list
If it exists, check the identifier name. Make sure that it is "closeButton" (Identifier is case sensitive, also spaces in the identifiers matters)
If the identifier is right, try to find out the closeButton's exact view hierarchy. Means, instead of just checking like app.buttons["closeButton"].exists, try like app.navigationBars.otherElements["someName"].buttons["closeButton"].exists
(This seems funny, but giving the exact location path of the element is a good practice, and it will work sometimes)
Note: This error "Failed to find Matching Element" on UI recording will happen if the system can not locate the element with proper identifier while doing action on it. So my guess is, your closeButton does not have proper identifier or it is not added to the current window.
Cheers!!

How to simulate a soft keyboard click on IOS simulator?

I am using XCTest to test my IOS app.
As part of a test case I need to enter a number into a field (which is not a text box)
When I record the test, following code is generated when I use the soft keyboard on the simulator(IPAD/IPhone)
app.staticTexts["0"].tap() //Line 1
app.typeText("23") //Line 2
When I execute the test, the soft keyboard pops up after Line 1. But when Line 2 is executed, following error appears
UI Testing Failure - Neither element nor any descendant has keyboard focus
My app requires to be installed on IPads/IPhones. So I need to make it run through the soft keyboard route only.
So I think typeText is not the correct method. What is the method to simulate clicks on a soft/virtual keyboard in an IOS simulator?
You need to call typeText() on the element with keyboard focus, not just app.
If the element was a text field, you would find the text field element and call typeText() on that.
let element = app.textFields["myTextField"]
element.typeText("23")
You will need to replace the query with your own one for finding the element which has keyboard focus. Usually, this would be a descendant of UITextField but you will need to use a more custom query if you are using a custom view instead.

iOS 8's documentContextBeforeInput only returns partial text

I am currently using iOS 8's provided keyboard extension's textDocumentProxy.documentContextBeforeInput to get the text that a user has entered in order to perform some sort of modification to it.
I noticed that while the method documentContextBeforeInput would work fine for any chucks of texts, as soon as periods "." are inserted, documentContextBeforeInput is only able to return text that occurs after the period.
For example, testing the following text: "This is sentence 1. And this is sentence 2" When using documentContextBeforeInput with placing the cursor at the end, it will only return "And this is sentence 2", and not the entire text that has come before it.
Has anyone also encountered this issue, and if so have you discovered a workaround?
Thanks!

iOS simulator cannot get custom location when debugging

After updating to Xcode 5.0.2, it seems that iOS simulator custom location option is not working propertly. When I prompt this
And reopen again the custom location dialog
I end getting the lat/lon values without decimals. Also, if I prompt a . instead of a comma, some times the dialog replaces the point with a comma, and sometimes deletes the decimal values. I've tried closing the simulator, changing hardware and restarting Xcode with no results.
There is a bug in the modal "Custom Location" window of iOS Simulator that affects users who have the comma set as the decimal number separator.
If you type the coordinates with the format XX,XX and you press OK, the numbers after the comma are truncated.
Try inputing both coordinates with the format XX.XXX ( 2 digits + a point (.) + 3 digits) then press OK, then quit the iOS Simulator. When you launch it again, it'll have the desired location.
If you go to the same "Custom location" windows you are going to visualize the coordinates in format XX,XX, but DO NOT PRESS OK in that windows, just press Cancel, because if you press OK they will be truncated again.
You can use this Macro #if (TARGET_IPHONE_SIMULATOR) and manually set a custom location in your code.
Hope it helps
It seems that the iOS Simulator is accepting only decimals with dot instead of comma.
For your language (spanish, I think), the Mac OS put comma in decimal numbers. I had the same problem because my Mac OS is in portuguese, that uses the comma as default for decimal numbers.
To change this setting, go to System Preferences > Language & Region > Advanced... and change the Decimal value in the number separators from comma (,) to dot (.) (you can change the currency separators if you want).
Than, every time you open the custom location prompt, decimal numbers of lat/lon values will appear with dot instead of comma.
I hope it has helped you, I couldn't post images because of my poor reputation.
In Xcode,Product -> Scheme -> Edit Scheme... (command + <).
Select Run/Debug from Side Menu, options tab Select "Allow Location Simulation" and select a default location to none. The default location is the reason for custom location changing.
Set your custom Lat/Long to Simulator...

Resources