Skip to content

Instantly share code, notes, and snippets.

@sebv
Created January 29, 2015 08:42
Show Gist options
  • Select an option

  • Save sebv/b437f5ee2dfce06bc8f0 to your computer and use it in GitHub Desktop.

Select an option

Save sebv/b437f5ee2dfce06bc8f0 to your computer and use it in GitHub Desktop.
iOSController._getPageSource = function (cb) {
if (this.isWebContext()) {
this.processingRemoteCmd = true;
var cmd = 'document.getElementsByTagName("html")[0].outerHTML';
this.remote.execute(cmd, function (err, res) {
if (err) {
cb("Remote debugger error", {
status: status.codes.UnknownError.code
, value: res
});
} else {
cb(null, {
status: status.codes.Success.code
, value: res.result.value
});
}
this.processingRemoteCmd = false;
}.bind(this));
} else {
this.getSourceForElementForXML(null, function (err, res) {
var xmlSource;
if (err || res.status !== 0) return cb(err, res);
try {
xmlSource = _xmlSourceFromJson(res.value);
} catch (e) {
return cb(e);
}
return cb(null, {
status: status.codes.Success.code
, value: xmlSource
});
}.bind(this));
}
};
iOSController.getPageSource = function (cb) {
var delayMs = 500;
setTimeout(this._getPageSource.bind(this, cb), delayMs);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment