Skip to content

Commit

Permalink
feat: next browser (#116)
Browse files Browse the repository at this point in the history
* feat: next browser

* docs: update readme

---------

Co-authored-by: xudafeng <[email protected]>
  • Loading branch information
yihuineng and xudafeng authored Oct 12, 2023
1 parent 51deab6 commit ac1e276
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Macaca WD Client is inspired by [admc/wd](//github.com/admc/wd), according to [W

## Contributors

|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1044425?v=4" width="100px;"/><br/><sub><b>ziczhu</b></sub>](https://github.com/ziczhu)<br/>|[<img src="https://avatars.githubusercontent.com/u/2139038?v=4" width="100px;"/><br/><sub><b>zhangyuheng</b></sub>](https://github.com/zhangyuheng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1209810?v=4" width="100px;"/><br/><sub><b>paradite</b></sub>](https://github.com/paradite)<br/>|[<img src="https://avatars.githubusercontent.com/u/4006436?v=4" width="100px;"/><br/><sub><b>meowtec</b></sub>](https://github.com/meowtec)<br/>|[<img src="https://avatars.githubusercontent.com/u/30293087?v=4" width="100px;"/><br/><sub><b>Jodeee</b></sub>](https://github.com/Jodeee)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1044425?v=4" width="100px;"/><br/><sub><b>ziczhu</b></sub>](https://github.com/ziczhu)<br/>|[<img src="https://avatars.githubusercontent.com/u/2139038?v=4" width="100px;"/><br/><sub><b>zhangyuheng</b></sub>](https://github.com/zhangyuheng)<br/>|[<img src="https://avatars.githubusercontent.com/u/1209810?v=4" width="100px;"/><br/><sub><b>paradite</b></sub>](https://github.com/paradite)<br/>|[<img src="https://avatars.githubusercontent.com/u/4006436?v=4" width="100px;"/><br/><sub><b>meowtec</b></sub>](https://github.com/meowtec)<br/>|[<img src="https://avatars.githubusercontent.com/u/10104168?v=4" width="100px;"/><br/><sub><b>yihuineng</b></sub>](https://github.com/yihuineng)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|[<img src="https://avatars.githubusercontent.com/u/11460601?v=4" width="100px;"/><br/><sub><b>zivyangll</b></sub>](https://github.com/zivyangll)<br/>|[<img src="https://avatars.githubusercontent.com/u/2720537?v=4" width="100px;"/><br/><sub><b>tsj1107</b></sub>](https://github.com/tsj1107)<br/>|[<img src="https://avatars.githubusercontent.com/u/10104168?v=4" width="100px;"/><br/><sub><b>yihuineng</b></sub>](https://github.com/yihuineng)<br/>|[<img src="https://avatars.githubusercontent.com/u/9957802?v=4" width="100px;"/><br/><sub><b>megolee</b></sub>](https://github.com/megolee)<br/>|[<img src="https://avatars.githubusercontent.com/u/7878020?v=4" width="100px;"/><br/><sub><b>kobe990</b></sub>](https://github.com/kobe990)<br/>|
|[<img src="https://avatars.githubusercontent.com/u/30293087?v=4" width="100px;"/><br/><sub><b>Jodeee</b></sub>](https://github.com/Jodeee)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|[<img src="https://avatars.githubusercontent.com/u/11460601?v=4" width="100px;"/><br/><sub><b>zivyangll</b></sub>](https://github.com/zivyangll)<br/>|[<img src="https://avatars.githubusercontent.com/u/2720537?v=4" width="100px;"/><br/><sub><b>tsj1107</b></sub>](https://github.com/tsj1107)<br/>|[<img src="https://avatars.githubusercontent.com/u/9957802?v=4" width="100px;"/><br/><sub><b>megolee</b></sub>](https://github.com/megolee)<br/>|[<img src="https://avatars.githubusercontent.com/u/7878020?v=4" width="100px;"/><br/><sub><b>kobe990</b></sub>](https://github.com/kobe990)<br/>|
[<img src="https://avatars.githubusercontent.com/u/29451458?v=4" width="100px;"/><br/><sub><b>centy720</b></sub>](https://github.com/centy720)<br/>|[<img src="https://avatars.githubusercontent.com/u/15025212?v=4" width="100px;"/><br/><sub><b>zhuyali</b></sub>](https://github.com/zhuyali)<br/>

This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Wed Jul 26 2023 20:31:43 GMT+0800`.
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Oct 12 2023 11:41:18 GMT+0800`.

<!-- GITCONTRIBUTOR_END -->

Expand Down
20 changes: 7 additions & 13 deletions lib/next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,31 @@
module.exports = wd => {
[
'page',
'pagePopup'
'pagePopup',
'browser'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
const [func, ...args] = params;
return this.next(method, [{ func, args }]);
const [ func, ...args ] = params;
return this.next(method, [ { func, args } ]);
});
});

[
'fileChooser',
'elementStatus'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
return this.next(method, params);
});
});

[
'fileChooser'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
return this.next(method, params);
});
});

[
'mouse',
'keyboard'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
const [type, ...args] = params;
return this.next(method, [{ type, args }]);
const [ type, ...args ] = params;
return this.next(method, [ { type, args } ]);
});
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macaca-wd",
"version": "4.2.2",
"version": "4.2.3",
"description": "Macaca webdirver API for Node.js",
"keywords": [
"macaca",
Expand Down
15 changes: 15 additions & 0 deletions test/utility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,19 @@ describe('test/utility.test.js', function() {
});
});
});
/**
* https://macacajs.github.io/macaca-wd/#browser
*/
describe('browser', async () => {
it('should work', async () => {
await driver.browser('version');
assert.equal(server.ctx.url, '/wd/hub/session/sessionId/next');
assert.equal(server.ctx.method, 'POST');
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: ''
});
});
});
});

0 comments on commit ac1e276

Please sign in to comment.