-
Notifications
You must be signed in to change notification settings - Fork 20
Support custom devtools server commands #21
Support custom devtools server commands #21
Conversation
Sorry, I am not the maintainer of webdriver_js_extender and I don't have knowledge of it. Probably @NickTomlin could review it? |
Thanks @qiyigg. @NickTomlin would you mind taking a look at this? |
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 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>; |
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.
We don't have a consistent pattern for naming, but what about something like sendChromiumCommand
to make the connection to the chromium tools clearer?
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.
Done.
lib/command_definitions.ts
Outdated
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'); |
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.
Just curious — since I am unfamiliar with these chromium commands — is there a practical difference between them besides not returning a result?
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.
Not really. I'm just exposing the two commands available in the devtools client. Not all devtools commands will necessarily return a result.
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
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 |
@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. |
@ventuno Is this using
|
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
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. |
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 looks good to me
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? |
Will publish it today. |
Thanks @qiyigg! |
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