diff --git a/lib/utils.js b/lib/utils.js index da1b424e..caee8178 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -4,6 +4,7 @@ import {errors} from 'appium/driver'; export const ADB_SHELL_FEATURE = 'adb_shell'; export const BIDI_EVENT_NAME = 'bidiEvent'; export const GET_SERVER_LOGS_FEATURE = 'get_server_logs'; +const COLOR_CODE_PATTERN = /\u001b\[(\d+(;\d+)*)?m/g; // eslint-disable-line no-control-regex /** * Assert the presence of particular keys in the given object @@ -64,9 +65,10 @@ export async function removeAllSessionWebSocketHandlers(server, sessionId) { * @returns {LogEntry} */ export function nativeLogEntryToSeleniumEntry (x) { + const msg = _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`; return toLogRecord( - _.isEmpty(x.prefix) ? x.message : `[${x.prefix}] ${x.message}`, - /** @type {any} */ (x).timestamp ?? Date.now() + /** @type {any} */ (x).timestamp ?? Date.now(), + _.replace(msg, COLOR_CODE_PATTERN, '') ); }