Skip to content

Commit

Permalink
Make sure keyboard closing deals with the native context (appium#831)
Browse files Browse the repository at this point in the history
* Make sure keyboard closing deals with the native context

* Single quotes
  • Loading branch information
imurchie authored Nov 19, 2018
1 parent 07131b4 commit 1c678f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
30 changes: 17 additions & 13 deletions lib/commands/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@ let commands = {}, extensions = {};
// then override anything we want below
Object.assign(extensions, iosCommands.element);

commands.getNativeAttribute = async function getNativeAttribute (attribute, el) {
if (attribute === 'contentSize') {
// don't proxy requests for the content size of a scrollable element
return await this.getContentSize(el);
}

// otherwise let WDA handle attribute requests
let value = await this.proxyCommand(`/element/${el}/attribute/${attribute}`, 'GET');
// Transform the result for the case when WDA returns an integer representation for a boolean value
if ([0, 1].includes(value)) {
value = !!value;
}
// The returned value must be of type string according to https://www.w3.org/TR/webdriver/#get-element-attribute
return (_.isNull(value) || _.isString(value)) ? value : JSON.stringify(value);
};

commands.getAttribute = async function (attribute, el) {
el = util.unwrapElement(el);
if (!this.isWebContext()) {
if (attribute === "contentSize") {
// don't proxy requests for the content size of a scrollable element
return await this.getContentSize(el);
}

// otherwise let WDA handle attribute requests
let value = await this.proxyCommand(`/element/${el}/attribute/${attribute}`, 'GET');
// Transform the result for the case when WDA returns an integer representation for a boolean value
if ([0, 1].includes(value)) {
value = !!value;
}
// The returned value must be of type string according to https://www.w3.org/TR/webdriver/#get-element-attribute
return (_.isNull(value) || _.isString(value)) ? value : JSON.stringify(value);
return await this.getNativeAttribute(attribute, el);
}
let atomsElement = this.getAtomsElement(el);
if (_.isNull(atomsElement)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ commands.hideKeyboard = async function (strategy, ...possibleKeys) {
} else {
// find the keyboard, and hit the last Button
log.debug('Finding keyboard and clicking final button to close');
if (await this.getAttribute('visible', keyboard) === 'false') {
if (await this.getNativeAttribute('visible', keyboard) === 'false') {
log.debug('No visible keyboard found. Returning');
return;
}
Expand Down

0 comments on commit 1c678f7

Please sign in to comment.