Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Support custom devtools server commands #21

Merged
merged 7 commits into from
Aug 7, 2018

Conversation

ventuno
Copy link
Contributor

@ventuno ventuno commented Jul 29, 2018

ChromeDriver version 2.30 [1] will support 2 new endpoints to send custom commands to the DevTools debugger server:

  • /chromium/send_command;
  • /chromium/send_command_and_get_result.

In this PR, I add the support for these new commands to the webdriver-js-extender.

[1] https://chromium.googlesource.com/chromium/src/+/711de0efbb675bd2a4a28ec47c9194d8e498e600

@ventuno
Copy link
Contributor Author

ventuno commented Jul 29, 2018

@qiyigg (or @sjelin) I figured out what was wrong with my previous PR [1]. I fixed the commits with the correct username/email address. This should be good to go.

[1] #13

@qiyigg
Copy link
Contributor

qiyigg commented Jul 30, 2018

Sorry, I am not the maintainer of webdriver_js_extender and I don't have knowledge of it. Probably @NickTomlin could review it?

@ventuno
Copy link
Contributor Author

ventuno commented Jul 31, 2018

Thanks @qiyigg. @NickTomlin would you mind taking a look at this?

Copy link
Contributor

@NickTomlin NickTomlin left a comment

Choose a reason for hiding this comment

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

This looks sane to me.

It's not the most friendly testing harness, but could you also add an entry to the table tests?

lib/index.ts Outdated
@@ -141,6 +141,10 @@ export interface ExtendedWebDriver extends WebDriver {

// See https://github.com/webdriverio/webdriverio/blob/v4.6.1/lib/protocol/shake
shakeDevice: () => wdpromise.Promise<void>;

sendCommand: (cmd: string, params: Object) => wdpromise.Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have a consistent pattern for naming, but what about something like sendChromiumCommand to make the connection to the chromium tools clearer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

export let sendCommand =
new CommandDefinition<void>('sendCommand', ['cmd', 'params'], 'POST', '/chromium/send_command');
export let sendCommandAndGetResult = new CommandDefinition<Object>(
'sendCommandAndGetResult', ['cmd', 'params'], 'POST', '/chromium/send_command_and_get_result');
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious — since I am unfamiliar with these chromium commands — is there a practical difference between them besides not returning a result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. I'm just exposing the two commands available in the devtools client. Not all devtools commands will necessarily return a result.

@ventuno
Copy link
Contributor Author

ventuno commented Aug 3, 2018

Thanks for the review @NickTomlin. I want to add these tests, but even without any changes I get a bunch of failures whenever I run npm test:

Failures:
1) table tests should correctly call "getCurrentContext"
  Message:
    Error: <spyOn> : could not find an object to spy upon for exec()
    Usage: spyOn(<object>, <methodName>)
  Stack:
    Error: <spyOn> : could not find an object to spy upon for exec()
    Usage: spyOn(<object>, <methodName>)

I'm following the instructions in CONTRIBUTING.md [1], am I missing something?

[1] https://github.com/angular/webdriver-js-extender/blob/master/CONTRIBUTING.md

@NickTomlin
Copy link
Contributor

@ventuno this is probably a bug in the existing tests. I will try to take a look at this and fix it on master first.

I can't promise i'll get to it before this weekend unfortunately.

@NickTomlin
Copy link
Contributor

@ventuno Is this using master? I was able to run npm test on master locally using node 6 and 10 🤔 can you:

  • post your OS/node version
  • try removing node_modules and npm installing again

@ventuno
Copy link
Contributor Author

ventuno commented Aug 7, 2018

Thanks a lot for the feedback @NickTomlin. I didn't realize I broke some existing tests by adding the two new commands. I fixed the issue and added the new tests, see the output of running npm test below:

> gulp test

[21:31:42] Using gulpfile ~/Documents/code/webdriver-js-extender/gulpfile.js
[21:31:42] Starting 'prepublish'...
[21:31:42] Starting 'format'...
[21:31:42] Finished 'format' after 99 ms
[21:31:42] Starting 'tsc'...
[21:31:45] Finished 'tsc' after 3 s
[21:31:45] Starting 'copy'...
[21:31:46] Finished 'copy' after 480 ms
[21:31:46] Finished 'prepublish' after 3.58 s
[21:31:46] Starting 'build'...
[21:31:46] Finished 'build' after 2.67 μs
[21:31:46] Starting 'test'...
Started
.................................................................


65 specs, 0 failures
Finished in 2.919 seconds

[21:31:49] Finished 'test' after 3.35 s

In order to structure the new mocks, I used the same structure used for appium's custom commands. Let me know if that makes sense to you.

Copy link
Contributor

@NickTomlin NickTomlin left a comment

Choose a reason for hiding this comment

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

💃

This looks good to me

@ventuno
Copy link
Contributor Author

ventuno commented Aug 7, 2018

Thanks a lot @NickTomlin. @qiyigg how do I get this merged? Also, do you happen to know if/when this is going to be released?

@qiyigg qiyigg merged commit 603b3f3 into angular:master Aug 7, 2018
@qiyigg
Copy link
Contributor

qiyigg commented Aug 7, 2018

Will publish it today.

@ventuno ventuno deleted the ftr-support-custom-devtools-cmds-2 branch August 7, 2018 19:28
@ventuno
Copy link
Contributor Author

ventuno commented Aug 7, 2018

Thanks @qiyigg!

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

Successfully merging this pull request may close these issues.

3 participants