Fails a simple test case using KIF - swift

I try to use KIF in swift project. I run test case on iPhone simulator. Probably I did not set up correctly KIF because use it first time. I used this manual
Test fails in this simple code
func testSelectingOrganizerRole() {
tester().tapView(withAccessibilityLabel: "ORGANIZE")
}
with reason:
A button with Accessibility label "ORGANIZE" exists on initial ViewConroller of storyboard.

Why don't you switch to the UI tests framework available since Xcode 7? A quick intro:
UI testing gives you the ability to find and interact with the UI of your app in order to validate the properties and state of the UI elements.
UI testing includes UI recording, which gives you the ability to generate code that exercises your app's UI the same way you do, and which you can expand upon to implement UI tests. This is a great way to quickly get started writing UI tests.
Using this framework, your simple test would look like this:
let app = XCUIApplication()
app.launch()
app["ORGANIZE"].tap()

Related

Flutter Firebase DebugView not sending events

Initially the person before me set up a screen observer so that whenever the page changes, setCurrentScreen is triggered to send a event and log the screen. Because we use a bunch of open containers to animate page opening, the screen observer doesnt get triggered. So I went through the app and added some setCurrentScreen for those that the screenObserver missed, and while there I also added some logEvents to see if people are using specific parts of the app.
The way I set enabled debug view was in xcode, going to Product -> Scheme -> Edit Scheme and adding -FIRAnalyticsDebugEnabled and -FIRDebugEnabled Edit scheme
After ticking both of the above (or just one or the other), only these events are being triggered then the app stops sending events. Completely. What am I missing? output
I cannot find another issue about this. I am using the same package name in the app and firebase, otherwise I would have no output. All other issues are talking about no output at all. I have tried to do this on simulator and on actual iPhone and they both yield the same result. I have also set up a android emulator and have an actual phone. Tried it on both and same result. The above screenshot is from iPhone as I am on Mac and more comfortable working on a iPhone.
i have set IS_ANALYTICS_ENABLED to true in the .plist file and this did not work

Xcode 8: UI Testing, Neither element not any descendant has keyboard focus

I've recently started to use UI testing within Xcode. I was able to record the test and play it back and it worked perfectly fine. I recently changed the accessibility labels for textFields to make the test look cleaner by giving it a better name.
However, now when I record the UI test and play it back again to test it, I get an error "Neither element not any descendant has keyboard focus.". I've attempted to uncheck hardware keyboard as mentioned in other posts, but that doesn't work for me.
//test login with username and empty password
let app = XCUIApplication()
let elementsQuery = app.scrollViews.otherElements
let emailtextfieldElement = elementsQuery.otherElements["emailTextField"]
let passwordtextfieldElement = elementsQuery.otherElements["passwordTextField"]
emailtextfieldElement.tap()
passwordtextfieldElement.tap()
emailtextfieldElement.tap()
app.typeText("wayne#test.com")
passwordtextfieldElement.tap()
app.buttons["Login - signInButton"].tap()
Anybody know the fix for this?
Use typeText on emailtextfieldElement instead of app.
let emailtextfieldElement = elementsQuery.otherElements["emailTextField"]
emailtextfieldElement.tap()
emailtextfieldElement.typeText("wayne#test.com")

Swift not printing to console with print() command, other code works fine

I am using XCode Version 9.0 beta (9M136h) to write an application with a watchkit extension. I can get the application to communicate with the watch app and send information back and forth using the WatchConnectivity Framework. I also have the app utilizing the AlamoFire framework to communicate with a server.
All my functions are being called and executing, however, i cant seem to get print() to log anything to the console! I have tried placing various print() commands in different areas of the application, but none of them are producing anything to the console, even though the code around them is working.
I am 100% sure that I am looking at the correct area of XCode, I have gone to View->Debug Area->Activate Console and I have also made sure that All output is selected. I even tried adding the OS_ACTIVITY_MODE with its value as disabled but that didn't seem to do anything, either.
Here is an example of how I am using it in my ViewController.swift file:
override func viewDidLoad()
{
super.viewDidLoad()
print("view did load")
initWCSession()
print("Attorney General Jeff Sessions")
}
This code runs and calls the initWCSession() function but I never see any output of "view did load" or "Attorney General Jeff Sessions" anywhere!
Is this is a bug in XCode? Is there something I am forgetting? (I am new to XCode).
Try view.backgroundColor = .red
I think view contoller is not being called. Just a guess. Otherwise printshould work.
I am not sure why this worked but I went into Edit Scheme and checked the checkboxes for logging malloc. I saved these settings and then went back into Edit Scheme and unchecked the boxes and saved.
After that, I started seeing the print() statements log to the console!
Must be a bug in this version of XCode.
On the recent Xcode 11.3.1 I was getting the log lines from CocoaLumberjack, but nothing from my print calls. Restarting Xcode fixed the problem.

Locating element in Xcode UI Test without accessiblity id

Recently I started learning XCode UI Test to write functional automation tests using UI testing feature of Xcode.
I need to read a text value of native app element. I can get the element with the help of text of element but the problem is I can not use the text as it is dynamic it will be changed after some time or next launch of app.
I am familiar with using WebDriver and Appium where I can tackle this with writing parent - child xpath.
Can anyone suggest a solution to this problem? Please post a sample code snippet as well with your solution as I am new to apple technology / swift.
Appreciate your help.
In your app's code, add an accessibility identifier to the element you want to inspect, then use that identifier to find the element in your UI test code.
// app code
let myLabel = UILabel()
myLabel.accessibilityIdentifier = "myDescriptionLabel"
// add other label configuration...
// UI test code
let app = XCUIApplication()
let descriptionLabel = app.staticTexts["myDescriptionLabel"]
let description = descriptionLabel.value as String

Cannot find window-based application on XCode

I am using XCode 4.2 and for some reason I cannot find the template for window-based application. Is there an extra step that I need to take here?
There is no longer a Window-based Application template starting from Xcode 4.2.
You have two other choices of "bare-bones" templates:
View-based Application template, which gives you a view on a storyboard to start with. It is similar to the one found in previous versions, except the view now resides on a storyboard which Xcode 4.2 makes use of.
Empty Application template, but you'll have to manually create and wire up a window nib file if you want to design your application in Interface Builder. It's nothing more than a trivial extra step, though.
If you can't make use of storyboards (e.g. to deploy to iOS 4 and earlier), you most likely need to go with the empty template. For the main window, just make a new Interface Builder file and assign it as your project target's Main Window.
Here are two very useful links:
The first one is a discussion on the Big Nerd Ranch forum where they discuss this issue - that the XCode 4.2 has done away with the Windows-template. They have a Template that you can use to add the "Windows-template" to your XCode installation. I have NOT tried this approach but you can try.
http://forums.bignerdranch.com/viewtopic.php?f=73&t=3336
As you dig through this thread - you will come on another site. This a blog post by Jeroen Trappers - on how to "manually" add the missing elements to an "Empty-application" template to make it "Window-template". I have followed these steps and they worked very well for me. In the process of going through these steps it does help you understand what is going on behind the scenes.Here is the URL to the post:
http://www.trappers.tk/site/2011/06/16/mainwindow-xib/
Window-based Application is now Empty Application. Just gives you an app delegate and a window. You build the rest.