Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ let desiredCapConstraints = _.defaults({
screenshotQuality: {
isNumber: true
},
skipLogCapture: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary if the desired capability is specified in appium-ios-driver.

Copy link
Member Author

@KazuCocoa KazuCocoa Feb 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove here after appium-boneyard/appium-ios-driver#355 and publish new version.
(In this PR or as another PR)

isBoolean: true
},
}, iosDesiredCapConstraints);

export { desiredCapConstraints };
Expand Down
14 changes: 12 additions & 2 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,20 @@ class XCUITestDriver extends BaseDriver {

await this.runReset();

let isLogCaptureStarted;
const startLogCapture = async () => {
const result = await this.startLogCapture();
if (result) {
this.logEvent('logCaptureStarted');
}
return result;
};
const isLogCaptureStarted = await startLogCapture();

if (this.opts.skipLogCapture) {
log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log line is repeated twice. Perhaps it would be better to move the check into the startLogCapture function on line 337?

const startLogCapture = async () => {
  if (this.opts.skipLogCapture) {
    log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.");
    return false;
  }

  const result = await this.startLogCapture();
  if (result) {
    this.logEvent('logCaptureStarted');
  }
  return result;
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense than mine 👍

} else {
isLogCaptureStarted = await startLogCapture();
}

log.info(`Setting up ${this.isRealDevice() ? 'real device' : 'simulator'}`);

Expand Down Expand Up @@ -385,7 +391,11 @@ class XCUITestDriver extends BaseDriver {
this.logEvent('simStarted');
if (!isLogCaptureStarted) {
// Retry log capture if Simulator was not running before
await startLogCapture();
if (this.opts.skipLogCapture) {
log.info("'skipLogCapture' is set. Skipping starting logs such as crash, system, safari console and safari network.");
} else {
await startLogCapture();
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions test/unit/driver-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down