Xamarin.uitest how to close app instance - xamarin.uitest

How to close and relaunch app in Xamarin.UI Test ? I want to restart app for each scenario in feature .
Platform: android
There is no quit() or close() session methods like we have in appium.

Calling ConfigureApp.Android.StartApp() in your test will launch a new session of your application for you to interact with (just make sure to save the new object).
However, with the use of NUnit, methods tagged with [Setup] will run automatically before every method tagged with[Test]. That means most test suites only use the ConfigureApp.Android.StartApp() method once, in [Setup].

Given you are on your are using Xamarin UI Test project,
You can use Finish() to close the application,
or
MoveTaskToBack(true) to minimize the application.
So that you can call them from your Test.cs, you'll need to write myBackdoorClose and myBackdoorMinimize functions (since Finish() and MoveTaskToBack(true) are only available in the App.cs context). How to do that, read here!

You can actually use Xamarin.UITest.ConfigureApp.Android.StartApp(AppDataMode.DoNotClear) in your test. It will close the app and restart it without clearing the app's data, all while the test keeps running.
This is a cross-platform solution; you can use Xamarin.UITest.ConfigureApp.iOS.StartApp... too.

Related

How to check if the biometric scanner is available and initialized in Xamarin android BiometricPrompt

Failed biometric(fingerprint) scan attempts are handled by OnAuthenticationFailed() callback of BiometricPrompt.AuthenticationCallback class.
The behavior I noticed is, it lets the user attempt 5 invalid fingerprint scans (each time the fail callback is invoked) and then the prompt dismisses. Within the next 30 secs, if we try to re-build a BiometricPrompt instance and try to authenticate, it does not show the prompt which I think is the default behavior of BiometricPrompt.
Is there anyway to check if the biometric scanner is available and initialised if the user attempts to re-invoke biometric prompt within the said 30secs?
How can I handle that use case?
xamarin android BiometricPrompt.AuthenticationCallback does not have an override method "onAuthenticationError" to handle error callbacks and thus I'm unable to handle error code "BIOMETRIC_ERROR_TIMEOUT".
If someone has a solution for this, please do let me know your resolution.
I believe that BiometricPrompt is not fully ported to Xamarin yet...
I'm still looking for a source that can double check this info for me, but I haven't found it either.

Symfony - background task from form setup

Would you know how to run a background task on Symfony 4, based on the setup of a form ? This would avoid that the user has to remain on the form until the task is finished.
The idea would be that when the form is validated, it starts an independant background task. Then the user can continue its navigation and come back once the task is finished to get the results.
Thanks for your help,
You need to use pattern Message Bus. Symfony has own implementation of this pattern since version 4.1 introducing Messenger Component.
You can see documentation here: https://symfony.com/doc/current/components/messenger.html
To get it work you need some external program that will implement AMQP protocol. Most popular in PHP world IMHO RabbitMQ.
A very simple solution for this could be the following procedure:
Form is valid.
A temporary file is created.
Cronjob gets executed every five minutes and starts a symfony command.
The command checks if the file exists and if it's empty.
If so, the command works of the background task. But before this, the command write it's process id in the file to prevent from beeing excuted a second time.
Remove the file when the command has finished.
As long as the file exists you can show a hint for the user that the task is running.

How to get the user who initiated the process in IBM BPM 8.5?

How to get the user who initiated the process in IBM BPM 8.5. I want to reassign my task to the user who actually initiated the process. How it can be achieved in IBM BPM?
There are several ways to get that who initiated a Task , But who initiated a process Instance is somewhat different.
You can perform one out of the following :
Add a private variable and assign it tw.system.user_loginName at the POST of start. you can access that variable for user who initiated the process.(It will be null or undefined for the scenario if task is initiated by some REST API or UCA.)
Place a Tracking group after Start event . Add a input variable to it as username , assign it a value same as tw.system.user_loginName. So whenever Process is started entry will be inserted to DB Table.You can retrieve this value from that view in PerformanceDB.
Also there might be some table ,logging the process Instances details , where you can find the user_id directly.
I suggest you to look in getStarter() method of ProcessInstanceData API.
Official Documentation on API
This link on IBM Developerworks should help you too: Process Starter
Unfortunately there's not an Out Of The Box way to do this - nothing is recorded in the Process Instance that indicates "who" started a process. I presume this is because there are many ways to launch a process instance - from the Portal, via a Message Event, from an API call, etc.
Perhaps the best way to handle this is to add a required Input parameter to your BPD, and supply "who" started the process when you launch it. Unfortunately you can't supply any inputs from the OOTB Portal "New", but you can easilty build your own "launcher".
If you want to route the first task in process to the user that started the process the easiest approach is to simply put the start point in the lane, and on the activity select routing to "Last User In Lane". This will take care of the use case for you without requiring that you do the book keeping to track the user.
Its been a while since I've implemented this, so I can't remember if it will work elegantly if you have system steps before the first task, but this can easily be handled by moving the system steps into the human service to be executed as part of that call, rather than as a separate step in the BPD.
Define variable as string type and using script task to define the login user that use this task and assign it to your defined variable to keep to you in all of the process as initiator of the task.
You can use this line of code to achieve the same:
tw.system.user_loginName

WrongThreadException in WinRT async handler

WinRT project, C++/CX. I'm trying to load a PNG file into a WriteableBitmap. I'm setting the Source property to an IRandomAccessStream. To get a stream from file, one has to use an async operation - there's no sync file open in WinRT.
My async completion handler is executed, it seems, on a random worker thread. And in that handler, the most innocent operations (like constructing a new WriteableBitmap) cause a WrongThreadException. It's not reproducible from run to run.
What's going on? Should I chalk it up to pre-release funkiness?
Visual Studio 2012 RC, Windows 8 build 8400.
When you interact with UI elements, they need to be performed on the UI thread. The easiest way of ensuring that you're on the UI thread is to use the PPL continuations - if you use the create stream async APIs, then the lambda passed to the ".then" method should run in the thread context of the original thread - usually the UI thread.
If you can't get back to the UI thread via PPL, then use CoreDispatcher.RunAsync() and do your work in the lambda passed to RunAsync - that will always run on the UI thread.

Unique browser session with webdriver

Does webdriver maintain unique browser sessions by default when used with multiple threads i.e multiple tests in parallel? If not then how do I make it maintain unique sessions?
By
Using TestNG , we can open multiple browser session (firefox) and run tests.
I am closer to "no" - If I run my tests in Selenium Grid and some browser window "dies" (hangs up unexpectedly, because I am bad programmer), restarting the tests cause my webapp to tell me "another user with same user name is already logged in"
But in normal Selenium Webdriver, calling driver = new FirefoxDriver(); caused new session. Always.
You can use Grid configuration; It is exactly what you need.See here an example of parallel test run.
Grid can support multiple sessions. You can configure this when you register your node to the hub, using parameters : -maxSession x -browser browserName=firefox,maxInstances=x, where x represents desired number of sessions.

Resources