Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to log WinAppDriver logs to file #1175

Closed
snehansh opened this issue May 27, 2020 · 1 comment
Closed

Unable to log WinAppDriver logs to file #1175

snehansh opened this issue May 27, 2020 · 1 comment

Comments

@snehansh
Copy link

snehansh commented May 27, 2020

Before running a unit test, we must run WinAppriver.exe. While the test executes the log messages of the Selenium api calls gets logged to the console window of WinAppDriver.exe.
I am attempting to programmatically launch WinAppDriver.exe and have the logs of Selenium api calls logged to a log file. I am using Serilog to log.
In the log files, I see garbage characters like image

I have tried to use StartInfo.StandardOutputEncoding and set it to System.Text.Encoding.UTF8. I have also tried to set OutputEncoding to several other values like Encoding.Default and Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage).
Based on my research this looks like an encoding issue but I am unclear about how to proceed.
What am I missing? Is it possible to do what I am attempting to do? I will appreciate any inputs or guidance. Thanks.

I am implementing the process like below:

Process p=new Process();
p.StartInfo.FileName = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.OutputDataReceived += p_OutputDataReceived;
p.Start();
p.BeginOutputReadLine();
p.WaitForExit();
private static void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
 Serilog.Log.Information($"{e.Data}");
}

log

@snehansh
Copy link
Author

I was able to resolve the issue by using:
p.StartInfo.StandardOutputEncoding = System.Text.Encoding.Unicode;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant