Wednesday, May 25, 2022

Troubleshooting Appium Tests with a logfile

Sometimes you can run into issues when you run Appium. This can be caused by a driver mismatch or a version upgrade of Appium, or some configuration change on your machine. But how do you figure out what is going wrong?

The best way to troubleshoot is to get your hands on the log file that Appium can produce. But where is it located? That was my major issue when troubleshooting. The log files themselves often contain a ton of good information to help you solve the problem.

How to set up the logfile?

You can get a log file by adding a startup command-line argument and specifying the log location. So when you run your tests from a build or a test in, e.g., Visual Studio, the best way to get your log files consistently is by specifying this in your test setup code.

Most of my time in coding I spend using C#. So when you use the Appium test engine with C# you can use the class ServerBuilder. ServerBuilder has the option to use the .WithLogFile option where you can specify the location of the logfile.

You can write your code as follows to startup your test and always have a log file as part of your test run:

I assume you are using MSTest as the test framework in this code sample since I use the TestContext to obtain a location where I want to have the logfile published.

avatar
Marcel de Vrieshttp://www.fluentbytes.com/
I am the co-founder and CTO of Xpirit, a high end consulting firm based in Hilversum, Netherlands. I spend most of my time looking at how new emerging technologies, a shift in mindset and a new way of work, can help organizations get software in production faster. Helping organizations transform towards a high speed, innovative and productive organization has become my passion. I love to learn new technologies and teach others what I have learned. Besides my work as CTO I also work as a consultant in the field of Application Lifecycle Management, Continuous Delivery, DevOps, Cloud/Web scale application architectures and Cross platform Enterprise Mobile app development with Xamarin.

Related Articles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay Connected

6,065FollowersFollow
5,933FollowersFollow

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Latest Articles