Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import _ from 'lodash';
import { errors } from 'appium-base-driver';
import { iosCommands } from 'appium-ios-driver';
import { util } from 'appium-support';
import { retryInterval, retry } from 'asyncbox';
import log from '../logger';
let commands = {}, extensions = {};
// pull in all the element commands and helpers from ios-driver,
// 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);
}
el = util.unwrapElement(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