mardi 26 mars 2019

Log Appium testresults to console (C#)

Appium wont log the test results (of the UI-tests, executed with adb emulator) to the debug output (Deug.WriteLine).

According to the documentation, get test logs is possible with the following line

ILogs logs = driver.Manage().Logs;

Hower, Appium has different log types:

  • Browser
  • Client
  • Driver
  • Profiler
  • Server

I tried every single log type with the following code. But by executing this I don't get any result and the test (where I put the code) fail. Does anyone have a solution for this problem?

        ReadOnlyCollection<LogEntry> logs = _driver.Manage().Logs.GetLog(LogType.Browser);
        //  ReadOnlyCollection<LogEntry> logs = _driver.Manage().Logs.GetLog(LogType.Client);
        //  ReadOnlyCollection<LogEntry> logs = _driver.Manage().Logs.GetLog(LogType.Driver);
        //  ReadOnlyCollection<LogEntry> logs = _driver.Manage().Logs.GetLog(LogType.Profiler);
        //  ReadOnlyCollection<LogEntry> logs = _driver.Manage().Logs.GetLog(LogType.Server);

        foreach (var log in logs)
        {
            Debug.WriteLine("Time: " + log.Timestamp);
            Debug.WriteLine("Message: " + log.Message);
            Debug.WriteLine("Level: " + log.Level);
        }

Aucun commentaire:

Enregistrer un commentaire