I tried to get my app name in UITesting. I tried the code below:
let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
But it gives me the nil value result.
Localize App Name and Authorization requests with Info.plist To localize your Info.plist content, add a new strings file to your project (as in step 1), and name it InfoPlist.strings. For the App name, the CFBundleDisplayName key is used by iOS to translate the app nane from Localizable.strings file.
So, to find an iOS Apps bundle ID you need to take couple steps as covered below – Steps to find the bundle ID for an iOS app ? Step 1: Search for the App Name on Google Search using your Desktop browser like Chrome, Firefox etc and open apps itunes/app store link.
When you’re ready to test, go to a test class and place the cursor inside the test method to record the interaction. From the debug bar, click the Record UI Test button. Xcode will launch the app and run it. You can interact with the element on-screen and perform a sequence of interactions for any UI test.
Creating a new UI test target for your project consists of two files with a default template. One is for regular UI tests and the other for launch tests. The former consists of two methods for the lifecycle of the test case: setUpWithError () – before each test method in a test case, you can reset the state and throw errors.
When I was trying to find out if the 'debugDescription' provides any information about the actual app (and not the test app) I stumbled across a label that looked exactly like the app's display name.
I don't know if it helps you, but the following simple line of code helped me:
XCUIApplication().label
Are you sure, that you've set Display name in your Info.plist file? Just set this name in Project settings or in Info.plist:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With