Posts

Post not yet marked as solved
1 Replies
My reply is probably too late for you, but i figured others might have a similar problem. I solved this by having Strings always be run through a helper function that picks the string from a localizable.plist just like you'd do in the app. func localizedString(key:String) -> String { let localizationBundle = Bundle(path: Bundle(for: AppUITests.UITestBase.self).bundlePath) let result = NSLocalizedString(key, bundle:localizationBundle!, comment: "") return result } Usage in your example would be: if XCUIApplication().keyboards.buttons[localizedString(key: "hideKeyboard")].exists { 		XCUIApplication().keyboards.buttons[localizedString(key: "hideKeyboard")].tap() } if XCUIApplication().keyboards.buttons[localizedString(key: "dismissKeyboard")].exists { 		XCUIApplication().keyboards.buttons[localizedString(key: "dismissKeyboard")].tap() } hideKeyboard and dismissKeyboard refer to the related String in each localizable.plist which you either provide yourself or link to within your Bundle Settings. This approach also allows you to create Tests that run on any device-language without having to rely on Accessibility-IDs which results in a more blackbox like environment.