I am using default test automation Framework provided by UiPath for mobile test cases. Now during any exception failure it was taking screenshot of the Orchestrator window machine where execution is happening instead of the mobile device.
Now with some research I found that I have to take the screenshot within the Mobile device connection activity, so I did changes in the Exception of Run sequence in Framework. I added the Mobile device connection and passed the Global mobile connection and placed the Verify activity so that it should take screenshot of the Mobile Page where the failure occurs.
Now even after doing these changes during exception it does not take screenshot and gives error message: A screenshot of the assertion could not be taken because there is no active desktop. Ensure that your process is not configured to start in background if you want screenshots to be taken. Internal error: Parameter is not valid.
Does anyone know how to take the screenshot of the Mobile Page during exception failure at framework level?
Thanks and Regards,
Milind Kumar
Use the Take Screenshot activity inside the Mobile Device Connection scope instead of desktop scope.
Pass the global mobile session object to ensure the screenshot is captured from the device.
Verify the test case is not set to run in background mode, as screenshots require foreground execution.
Thanks, but this is what I am doing almost same. In Catch, I am using Mobile device connection, Passing the global mobile session, within that Mobile device connection i am using the Verification activity to take screenshot, test case is always running in foreground execution, still getting the above error during exception failure.
Can you try using Mobile.Take Screenshot inside the Mobile Device Connection instead of Verify.
Can you try re-initializing the mobile session in Catch so the connection stays active.
Can you try saving the screenshot path and attaching it to the test report for validation.
@Mir.Jasimuddin , I have tried all the above options already and still it is not capturing the screenshot of mobile device and I am getting the same error message. Please find the screenshot attached for exception what I am using. Do you have a solution for this issue?
Use Mobile.Take Screenshot activity inside Mobile Device Connection.
Reinitialize the mobile session in Catch before taking screenshot.
Save the screenshot path and attach it to the report for validation.
@Mir.Jasimuddin I have pasted the above screenshot and said I have tried the same thing before what you are giving as solution.
Use Mobile.Take Screenshot activity inside Mobile Device Connection.
Reinitialize the mobile session in Catch before taking screenshot.
Save the screenshot path and attach it to the report for validation.
It is still not working. Do you have a solution for this issue?
@Mir.Jasimuddin , It was already there in my first post itself. Here is the error message again: A screenshot of the assertion could not be taken because there is no active desktop. Ensure that your process is not configured to start in background if you want screenshots to be taken. Internal error: Parameter is not valid.
Hi! Yes. You’re using the wrong activity. Verify will always take screenshot of the desktop. In order to take a mobile device screenshot you have to use the mobile specific take screenshot Activities - Take Screenshot
@phaserescu , Let me give you the high level background of my project. I am working on mobile automation project. I understand and agree that Verify will always take the screenshot of the desktop, but if you use the same Verify expression inside the Mobile device connection then it starts taking screenshot of the Mobile screen instead of the desktop and pushes to the orchestrator and this works fine. So I dont need to use the mobile specific take screenshot activity.
We are using the UiPath Default Test automation Framework to run my mobile test cases. The default framework will use Set Up , then Run and Finally Tear down xaml file. In the run section it is calling my mobile test cases to execute and whenever there is exception it goes through the catch section of the Run file. Now by default in the catch section verify activity was there so it was taking desktop screenshot as it was not inside Mobile device connection. So I added the Mobile device connection and inside that using the verify activity and expecting it should work in the same way as it is working in my test cases and taking mobile screenshot. Now this time it stops taking any screenshot and giving me the error message in the Orchestrator which I mentioned in my original post. I have also provided the screenshot of my catch section.
Now my situation is withing my test case the if Verify activity is inside the mobile device connection it takes the mobile screenshot , but the same thing is not
@Mir.Jasimuddin , the short answer is the solution which you are giving to me is not working that is why I am asking same question.
Now this could be learning for you, I wanted to tell you that if you use Verify activity inside Mobile device connection it will automatically start taking Mobile screenshot and it will not take the desktop screenshot. So no need to use Mobile specific take screenshot activity.
My only thing is if I am using the verify activity inside the Mobile device connection in the catch section then it is not taking any screenshot neither mobile nor desktop.
So why it is behaving differently here but it works fine in the test case level. So if you know any solution which will take screenshot of mobile device and post to orchestrator during exception, please let me know.
I’m not sure exactly what isn’t working. I looked a bit at the code and saw that verify has the ability to have its screenshot function overridden (probably for these types of scenarios). Keeping this in mind I suspect that the context influences this but in this case multiple sources try to override the same screenshot functionality.
One workaround that comes to mind is to move the part with MobileDevice Connection and verify activity into a separate workflow, and pass the connection as an argument and call that workflow from catch. The difference in this case should be that the context of the separate workflow shouldn’t be influenced by the parent activity (just a guess).
@phaserescu , Thanks for your suggestion and I was hoping that it should work, but It still did not work and I got the same error message " A screenshot of the assertion could not be taken because there is no active desktop" . I am suspecting if using the sequence inside the Catch activity is overriding something here. Do you suggest to open a ticket with UiPath or any other solution?