Can I manipulate Web pages from Xcode UI Testing? - xcode

I have my test cases written in Swift3 UI Testing in Xcode, my test cases run in an iOS application in simulator. One of our functionalities is bring assets into our app from dropbox, whenever we tap on dropbox icon (from our app) the dropbox web site opens to allow the user to LogIn. my question is, is there any way to use swift code that can automate the logIn on the web site? I would like to automate all that process.

No, there is no way to use XCTest UI tests to test anything other than an application you created.
The tests are only able to interact with a single application, and the bundle ID must match the bundle ID in the Info.plist for the UI tests.

Related

How can I add files to the iOS simulator in a CI environment?

I would like to include a UI test in my project that exercises its interaction with UIDocumentPickerViewController. The test will need to run on a CI machine, which needs to be able to wipe the simulator before each build, and operate without a human driving the GUI (either on the machine or the simulator).
There are a number of answered questions around how to add files to the iOS simulator, but they seem to all require manual interaction with the simulator UI. What I've tried so far:
Using xcrun simctl openurl file:///path/to/my%20file.pdf, but that just presents a sheet in the files app that would need manual intervention to actually save to the simulator.
Using xcrun simctl addmedia, but the media need to be images or videos and they end up in PHPickerViewController and not UIDocumentPickerViewController.
Using the openurl command above before the test kicks off and then adding a button in my app to open the shareddocuments:// URL to present the Files app, and using the UI test runner to click the "On My Phone" and "Save" buttons. This looks promising but also promises to be flaky.
What I haven't tried yet:
Set up a sockpuppet iCloud account and log the simulator into that account on every test run in order to use iCloud Drive. This seems like yet another credential to manage that will randomly break when it needs to agree to some new terms and conditions.
Replace my test app with a document-based app and figure out how to save a file from the bundle to its file storage without manual interaction. I'd love a guide on how to do this but it feels like I could easily spend a week getting up to speed on document-based apps to get it working.
The code I'm testing is a framework, so the app under test is free to have features that would make no sense to an actual user and is also free to do non-app-store-safe things. But it seems like other developers might appreciate a more general solution if you have one.

UI Automation for AppleTV system using XCode

Is UI automation available for the main menu of the Apple TV and not a specific application? I already setup the whole UI testing thing using XCode and tried using the remote control but it is only available for the application that was defined using XCUIApplication.
So is it possible to control the whole system rather than a specific application? I was thinking of something similar to pyatv but using XCode since I might be able to get more information concerning the current focused apps and so on.
There is an API XCUIApplication(bundleIdentifier: ) to interact with not-AUT apps. You need to substitute the right identifier for this Springboard-like interface. Maybe it is a Headboard, but I'm not sure.
Bundle identifiers of tvOS apps https://github.com/rzakhar/XCTApps/blob/master/Sources/XCTApps/tvOS.swift

Xamarin UITest [IOS]: Share file from app through automation

I am using Xamarin.UITest to automate iOS app test. I have to automate file sharing from app through mail.
Do Xamarin UItest supports file sharing for iOS ? Or is there any other 3rd party library available ?
Using UI Testing, you are not going to be able to perform actions in other apps.
If your app shares file and sends emails within itself, yes you can do that. But if it requires another app to perform the action, you can't.
You will just have to create a conditional that checks for the build configuration, and if it is a UITest, then execute different code so that your test is not locked in a state where it has no control.
Eg:App Review dialogs like this can't be UITested:

How can I share my slack app between my workspaces?

I've just created an app (slash command) and install it in one of my workspaces. But now I want to add the same app to another one. Is it possible without distribution to App Directory?
If you want to add you Slack app to another workspace, you can do so without going through the process of placing it on the App directory.
All you need to do is
add the ability to install your app to an workspace using OAuth 2.0.
enable public distribution
So instead of clicking "Install app to this workspace", which works great for private Slack app, which live in one workspace only, you need a script than can be called from a web browser to run the Oauth installation routine. This is usually done by adding a Slack button to your website.
You also need to enable "public distribution" for your app. Note, that is not the same as putting them on the App Directory, which requires submitting your app and undergoing a review by the Slack team.
Found the answer, in the small grey caption in the app creation form
Your app belongs to this workspace—leaving this workspace will remove your ability to manage this app. Unfortunately, this can’t be changed later.

is it possible to test web app using Xcui?

I am looking into Xcode and Xcui for web app and cannot get it work. to start up recording, build or whatsoever it needs a valid executable which I don't have since i am not building an app. is there any way to launch Safari as the app and then record it and run tests?
i know there's Appium and other tools but wondering if it's possible and if so I would be keen to implement some in swift.
NOTE: This is a super hacky way to get it done:
I think you would have to create a quick application that holds a web view in the app, that launches to your respective web page.
You can write automated tests for this app which will simply land you on your web page
You will not have access to elements, like table views, cells, or anything in the XCUIelement tree
You will have to do everything based on frames and coordinates
You can determine where all your elements are and set them up as variables and call them like this:
`let myButton = XCUIApplication().windows.element(boundBy: 0).coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.30))`
myButton.tap()
Not ideal but if you want to use swift to learn and move things around its possible
As far as XCUI testing is concerned, it was basically made to test the integration flow of an iOS app. As a result it can ONLY test native view controllers. As far as the web view is concerned, it should be tested at the web level and not at the application level.

Resources