We have an Android app. I create a lot of UI tests for this app. But sometimes when I’m running them - the app can be closed without any reason. And I cant understand why.
How can I create logs and understand why it happens and fix it
There is a driver method that will retrieve the system logs of the device you are using - logcat in the case of Android. In C# you can get the logs using Driver.Manage().Logs. Similar functionality will be available in other languages too. The way I use it is as follows:
- On initialisation of the test get and store the start time of the test
- In the test cleanup, if the test has failed get the logs
- Filter the logs based on the start to end time of the test
- Save the filtered log to a file
- You can also further filter the log file of other stuff you think will be unnecessary. there is a lot in it.
This way whenever you have a failed test these logs will be automatically saved.
i found this method but still didn’t try it:
To start the appium server in the terminal - appium --log-level debug --port 4723 --keep-alive-timeout 1800 --session-override --log-timestamp --use-plugins execute-driver --relaxed-security --allow-insecure=chromedriver_autodownload > appium_logs.txt