diff --git a/README.md b/README.md index bec3ddb29..d326fb19d 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ Differences noted here |`reduceMotion`| It allows to turn on/off reduce motion accessibility preference. Setting reduceMotion `on` helps to reduce flakiness during tests. Only fon simulators | e.g `true` | |`permissions`| Allows to set permissions for the specified application bundle on Simulator only. The capability value is expected to be a valid JSON string with `{"": {"": "", ...}, ...}` format. It is required that `applesimutils` package is installed and available in PATH. The list of available service names and statuses can be found at https://github.com/wix/AppleSimulatorUtils. | e. g. `{"com.apple.mobilecal": {"calendar": "YES"}}` | |`screenshotQuality`| Changes the quality of phone display screenshots following [xctest/xctimagequality](https://developer.apple.com/documentation/xctest/xctimagequality?language=objc) Default value is `1`. `0` is the highest and `2` is the lowest quality. You can also change it via [settings](https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/settings.md) command. `0` might cause OutOfMemory crash on high-resolution devices like iPad Pro. | e.g. `0`, `1`, `2` | +|`skipLogCapture`|Skips to start capturing logs such as crash, system, safari console and safari network. It might improve performance such as network. Log related commands will not work. Defaults to `false`. |`true` or `false`| ## Development diff --git a/lib/desired-caps.js b/lib/desired-caps.js index b767d9d06..0330a108d 100644 --- a/lib/desired-caps.js +++ b/lib/desired-caps.js @@ -165,6 +165,9 @@ let desiredCapConstraints = _.defaults({ screenshotQuality: { isNumber: true }, + skipLogCapture: { + isBoolean: true + }, }, iosDesiredCapConstraints); export { desiredCapConstraints }; diff --git a/lib/driver.js b/lib/driver.js index a395dfa29..6ffde0365 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -135,6 +135,7 @@ class XCUITestDriver extends BaseDriver { ]; this.resetIos(); this.settings = new DeviceSettings(DEFAULT_SETTINGS, this.onSettingsUpdate.bind(this)); + this.logs = {}; // memoize functions here, so that they are done on a per-instance basis for (const fn of MEMOIZED_FUNCTIONS) { @@ -333,7 +334,15 @@ class XCUITestDriver extends BaseDriver { await this.runReset(); + const memoizedLogInfo = _.memoize(function () { + log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network."); + }); const startLogCapture = async () => { + if (this.opts.skipLogCapture) { + memoizedLogInfo(); + return false; + } + const result = await this.startLogCapture(); if (result) { this.logEvent('logCaptureStarted'); diff --git a/test/unit/driver-specs.js b/test/unit/driver-specs.js index 05e53cd48..9bafbb62a 100644 --- a/test/unit/driver-specs.js +++ b/test/unit/driver-specs.js @@ -95,6 +95,23 @@ describe('driver commands', function () { const resCaps = await driver.createSession(caps); resCaps[1].javascriptEnabled.should.be.true; }); + + it('should call startLogCapture', async function () { + const c = { ... caps }; + Object.assign(c, {skipLogCapture: false}); + this.timeout(MOCHA_LONG_TIMEOUT); + const resCaps = await driver.createSession(c); + resCaps[1].javascriptEnabled.should.be.true; + driver.startLogCapture.called.should.be.true; + }); + it('should not call startLogCapture', async function () { + const c = { ... caps }; + Object.assign(c, {skipLogCapture: true}); + this.timeout(MOCHA_LONG_TIMEOUT); + const resCaps = await driver.createSession(c); + resCaps[1].javascriptEnabled.should.be.true; + driver.startLogCapture.called.should.be.false; + }); }); describe('startIWDP()', function () {