Skip to content

Commit

Permalink
feat: Make it possible to retrieve native logs being in web context (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored May 28, 2020
1 parent c93f1e1 commit f3845cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lib/commands/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import log from '../logger';
import os from 'os';
import _ from 'lodash';
import WebSocket from 'ws';
import { DEFAULT_WS_PATHNAME_PREFIX } from 'appium-base-driver';
import { DEFAULT_WS_PATHNAME_PREFIX, BaseDriver } from 'appium-base-driver';

const GET_SERVER_LOGS_FEATURE = 'get_server_logs';

Expand Down Expand Up @@ -121,6 +121,22 @@ commands.mobileStopLogsBroadcast = async function mobileStopLogsBroadcast () {
await this.server.removeWebSocketHandler(pathname);
};

commands.getLogTypes = async function getLogTypes () {
const nativeLogTypes = await BaseDriver.prototype.getLogTypes.call(this);
if (this.isWebContext()) {
const webLogTypes = await this.chromedriver.jwproxy.command('/log/types', 'GET');
return [...nativeLogTypes, ...webLogTypes];
}
return nativeLogTypes;
};

commands.getLog = async function getLog (logType) {
if (this.isWebContext() && !_.keys(this.supportedLogTypes).includes(logType)) {
return await this.chromedriver.jwproxy.command('/log', 'POST', {type: logType});
}
return await BaseDriver.prototype.getLog.call(this, logType);
};

Object.assign(extensions, commands, helpers);
export { commands, helpers };
export default extensions;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dependencies": {
"@babel/runtime": "^7.0.0",
"appium-adb": "^8.1.0",
"appium-base-driver": "^6.0.0",
"appium-base-driver": "^6.2.0",
"appium-chromedriver": "^4.13.0",
"appium-support": "^2.47.1",
"async-lock": "^1.2.2",
Expand Down

0 comments on commit f3845cc

Please sign in to comment.