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

Update tooling and protocols #19

Merged
merged 21 commits into from
Oct 25, 2017
Merged

Update tooling and protocols #19

merged 21 commits into from
Oct 25, 2017

Conversation

svatal
Copy link
Contributor

@svatal svatal commented Aug 12, 2017

  • merged abandoned georgiosd's PR Update tooling and protocols #15
  • some other updates (protocols from Chrome 60, headless mode, example takes screenshot of the page, SendAsync returns correct response)

var chromeProcessArgs = remoteDebuggingArg + " " + userDirectoryArg + " --bwsi --no-first-run";
var remoteDebuggingArg = $"--remote-debugging-port={port}";
var userDirectoryArg = $"--user-data-dir=\"{directoryInfo.FullName}\"";
const string headlessArg = "--headless --disable-gpu";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we forcing headless here? I'm not comfortable doing this, unless others feel strongly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add an option.

public interface IChromeSession
{
Task<ICommandResponse> SendAsync<T>(T parameter, CancellationToken cancellationToken);
Task<CommandResponse<TResponse>> SendAsync<TResponse>(ICommand<TResponse> parameter, CancellationToken cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? There was a reason it was just returning the interface. I'm having a hard time recalling the reason though. @qmfrederik do you have thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, now I see there is second implementation of ICommandResponse - ErrorResponse. And it can be returned from the task ..
I'd personally prefer setting task to faulty in such cases than to be forced to check and retype every command. What are your thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran through the history via git blame but I don't think I changed this to return an interface, it looks like it just always has been like that. (I did submit a bunch of other PRs to return interfaces in other areas, but not here).

I think this change is OK, since CommandResponse<T> is a very simple class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i really like this change, i'm just afraid of "breaking" other people using this.

await chromeSession.SendAsync(new SetVisibleSizeCommand {Width = ViewPortWidth, Height = height});

Console.WriteLine("Taking screenshot");
var screenshot = await chromeSession.SendAsync(new CaptureScreenshotCommand {Format = "png"});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like this change ... it does seem like more advanced example. Would you be opposed to making a Simple and Advanced sample? Then we can link them from the README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean keeping the original sample too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ... maybe we can even make it simpler

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something for later though

@qmfrederik
Copy link
Contributor

@svatal Do you think it would be possible to split off the protocol update in a separate PR? That would make the PR easier to review 😄 .

@svatal
Copy link
Contributor Author

svatal commented Oct 25, 2017

@qmfrederik Hmm, I do not see a easy way how to do it - both code and protocol changes depends on each other. I had to fix protocol generator after updating protocol and on the same time the newly generated code is needed to return correct result from SendAsync

@brewdente brewdente merged commit c4bdc6d into MasterDevs:master Oct 25, 2017
@qmfrederik
Copy link
Contributor

@brewdente Cool to see this got merged. Any chance we get an updated NuGet package, too? 😄

@svatal
Copy link
Contributor Author

svatal commented Oct 26, 2017

@brewdente Really happy to see the changes merged, but what about the ErrorResponse?
Before, it has been an user's obligation to check the response if no error was returned and just then cast it to correct response type (although I doubt people were doing it).
Now, the error case is unhandled and it will throw while casting and the ErrorResponse will be lost.
What can be done from my point of view:
a) throw intentionally with the ErrorResponse included
b) return a proxy-response that will have isError, Result and Error and throw nice error when accessing the wrong getter.
I was initially rooting for the a) case, but while polishing the b) case, it seems to be perfectly suitable to both usages (either checking for error first or going the happy path), so I'll try to implement the second option.

@svatal
Copy link
Contributor Author

svatal commented Oct 26, 2017

should be solved in PR #23

@brewdente
Copy link
Member

@qmfrederik heh ... i was doing it anyways. but i'm glad you were a fan of it too. I questioned the nuget version number ... ultimately went with 1.1.0 (which I think is right semantically).

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

Successfully merging this pull request may close these issues.

4 participants