How print Appium Studio logs on C#?

Hi Team,

I’m using C# on Visual Studio to write test with Appium Studio 10.9. While running my test I couldn’t see any server logs getting printed on the Visual Studio console. But for Java I could see the logs printed for the same test in Eclipse

Could you please share any suggestions to overcome this

Thanks,
Saravanan

Hi,
This is related to the C# client. I couldn’t find a way to configure the C# client to print log message to the console.
You can find more information on the C# client in the following url:

Thanks Guy! Myself even couldn’t find suitable solution from C# native client.

Is there a capability to write the logs to external file OR view the directly in Appium Studio itself ?

Thanks,
Saravanan

Hi @Saravanan_Palanivel

There doesn’t seem to be any built-in logging capabilities in Appium for .NET.

Perhaps NUnit could be the solution in your case. It implements a class called TestContext that allows you to retrieve and log info, parameters and events.

Thanks a lot Nivi! Already am using TestContext from nunit to print runtime logs, but i am looking for Appium server logs to get printed.

Hi Nivi,

Is there any plan to show up server logs on the console of Appium Studio for C# client ?

Thanks,
Saravanan

Hi @Saravanan_Palanivel

I might be able soon to provide you with a code that will let you print logs to the console.
Stay tuned!

Awesome! thanks Nivi! Looking forward to have that!

@Saravanan_Palanivel

You can download the demo project from our repository

Download as zip, extract, and open in VS.

Once you finish running your tests, you will be able to see the log in the output (we use TestContext.Out.WriteLine to print the log)

Thanks Nivi!

I was trying to run the test TestUntitled (Android), but ended up with below exception. Could you please assist with this

Thanks,
Saravanan

Hi @Saravanan_Palanivel

Have you made any changes to the base code?

Can you copy paste the code (test class) so we can examine it?

Thanks Nivi!

I was using below test method, and it throwing exception. But when i downloaded the latest revision of it, I am not sure, it have been removed & i could see TestUntitled() as Empty.

    [Test()]
    public void TestUntitled()
    {
        TestContext.WriteLine("----- Last  -----");
        TestContext.WriteLine(driver.Manage().Logs.AvailableLogTypes);
        System.Collections.ObjectModel.ReadOnlyCollection<String> avLogs = driver.Manage().Logs.AvailableLogTypes;
        System.Collections.ObjectModel.ReadOnlyCollection<LogEntry> logs = driver.Manage().Logs.GetLog("logcat");

        foreach (String log in driver.Manage().Logs.AvailableLogTypes)
        {
            TestContext.WriteLine(log);
        }
    }

Thanks,
Saravanan

Hi @Saravanan_Palanivel

This problem seems to be with Appium C# client.

If I run the code using the original Android Driver, I get
System.InvalidOperationException : unknown command (Unknown command)
When the debugger hits the command
TestContext.WriteLine(driver.Manage().Logs.AvailableLogTypes);

So it seems that the issue is with the command itself, not the extension of the drivers.

Thanks Nivi! That’s really unfortunate!

@Saravanan_Palanivel

It’s really unfortunate that we were unable to get this to work for you.

If I find the time, I’ll try to dig deeper into this issue to see if I can get this to work.

Feel free to ping this thread to remind me about this issue.