-
Notifications
You must be signed in to change notification settings - Fork 292
chore: add support for dotnet tool/CLI #1426
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
Conversation
src/Playwright.CLI/Program.cs
Outdated
| pwProcess.Start(); | ||
|
|
||
| pwProcess.WaitForExit(); | ||
| Console.WriteLine(pwProcess.StandardOutput.ReadToEnd()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should inherit stdio streams to get incremental input/output/errors, instead of writing something at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that having RedirectStandardOutput set to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kblok the default is false - so I think we do, if we want to see the input/output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry. I mean, if we have RedirectStandardOutput = true do we need to write the output to the console. Doesn't RedirectStandardOutput do that for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I assumed that too, but it didn't. I'll give it another go, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, look at that, turns out you have to call BeginOutputReadLine, to get anything on the event handlers :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done, now. For now, I'm assuming that what I get is a direct WriteLine, so I don't support some scenarios, like the app clearing the output. But I think this will be fine for v1.
|
|
||
| private static string GetFullPath() | ||
| { | ||
| string envPath = Environment.GetEnvironmentVariable(DriverEnvironmentPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who sets this env variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be the user calling the tool. If there's none set, we get a null and do fallback.
README.md
Outdated
|
|
||
| ### Driver Discoverability | ||
|
|
||
| By default, the tool will attempt to look at `%USERPROFILE%\.nuget\packages\microsoft.playwright` for the location of the driver. If that behaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the tool pick up Playwright from my project, if I am at src/?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the behaviour and doc now:
- traverse current folder and find
.playwright - NuGet cache
| pwProcess.BeginOutputReadLine(); | ||
| pwProcess.BeginErrorReadLine(); | ||
|
|
||
| pwProcess.WaitForExit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stackoverflow says this is going to block, and so we won't see live updates. Perhaps we should await for process.Exited event to unblock the thread so it can perform live streaming of the output? I am also not sure what WaitOne(5000) is for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll block the calling thread, yes, but it launches the process from a different thread and the callbacks happen on other threads:
The WaitOne is to ensure that we don't make the same mistake as our tests did initially - disposing stuff before we get all the content. We either wait for null to be sent as the payload, when the stream is done, or 5 seconds after the process exited which likely means there was a problem in the stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

No description provided.