Github user vladimir-kotikov commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-camera/pull/202#discussion_r59190313
--- Diff: appium-tests/ios/ios.spec.js ---
@@ -85,204 +84,187 @@ describe('Camera tests iOS.', function () {
}
function getPicture(options, cancelCamera, skipUiInteractions) {
+ var promiseId = getNextPromiseId();
if (!options) {
options = {};
}
- var command = "navigator.camera.getPicture(function (result) {
document.getElementById('info').innerHTML = 'Success: ' + result.slice(0, 100);
}, " +
- "function (err) {
document.getElementById('info').innerHTML = 'ERROR: ' + err; }," +
JSON.stringify(options) + ");";
+
return driver
- .sleep(2000)
.context(webviewContext)
- .execute(command)
- .sleep(5000)
+ .execute(cameraHelper.getPicture, [options, promiseId])
.context('NATIVE_APP')
.then(function () {
if (skipUiInteractions) {
return;
}
if (options.hasOwnProperty('sourceType') &&
options.sourceType === cameraConstants.PictureSourceType.PHOTOLIBRARY) {
return driver
- .elementByName('Camera Roll')
+ .waitForElementByXPath('//*[@label="Camera
Roll"]', MINUTE / 2)
.click()
.elementByXPath('//UIACollectionCell')
.click()
.then(function () {
- if (options.hasOwnProperty('allowEdit') &&
options.allowEdit === true) {
+ if (options.allowEdit) {
return driver
- .elementByName('Use')
- .click();
+ .elementByXPath('//*[@label="Use"]')
+ .click()
+ .fail(function () {
+ return driver
+
.elementByXPath('//UIAButton[@label="Choose"]')
+ .getLocation()
+ .then(function (loc) {
+ var tapChoose = new
wd.TouchAction();
+ tapChoose.tap(loc);
+ return driver
+
.performTouchAction(tapChoose);
+ });
+ });
}
return driver;
});
}
if (options.hasOwnProperty('sourceType') &&
options.sourceType === cameraConstants.PictureSourceType.SAVEDPHOTOALBUM) {
return driver
- .elementByXPath('//UIACollectionCell')
+ .waitForElementByXPath('//UIACollectionCell',
MINUTE / 2)
.click()
.then(function () {
- if (options.hasOwnProperty('allowEdit') &&
options.allowEdit === true) {
+ if (options.allowEdit) {
--- End diff --
Please invert this statement to reduce nesting. The code inside looks
overly indented.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]