From 8c5f8bbce35d37373aa362467aa7b9ec024f258a Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Thu, 7 Mar 2013 18:08:18 -0800 Subject: [PATCH] working on getting new iosatom working --- app/ios.js | 33 ++++++++++++++++++++--------- sample-code/examples/node/safari.js | 16 ++++++++++++-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/ios.js b/app/ios.js index a47778b24..7b3ed62df 100644 --- a/app/ios.js +++ b/app/ios.js @@ -438,21 +438,34 @@ IOS.prototype.setValueImmediate = function(elementId, value, cb) { }; IOS.prototype.setValue = function(elementId, value, cb) { - var command = ["au.getElement('", elementId, "').setValueByType('", value, "')"].join(''); - this.proxy(command, cb); + if (this.curWindowHandle) { + this.useAtomsElement(elementId, cb, _.bind(function(atomsElement) { + value = escapeSpecialChars(value, "'"); + this.remote.executeAtom('type', [atomsElement, value], cb); + }, this)); + } else { + var command = ["au.getElement('", elementId, "').setValueByType('", value, "')"].join(''); + this.proxy(command, cb); + } +}; + +IOS.prototype.useAtomsElement = function(elementId, failCb, cb) { + var atomsElement = this.getAtomsElement(elementId); + if (atomsElement === null) { + failCb(null, { + status: status.codes.UnknownError.code + , value: "Error converting element ID for using in WD atoms: " + elementId + }); + } else { + cb(atomsElement); + } }; IOS.prototype.click = function(elementId, cb) { if (this.curWindowHandle) { - var atomsElement = this.getAtomsElement(elementId); - if (atomsElement === null) { - cb(null, { - status: status.codes.UnknownError.code - , value: "Error converting element ID for using in WD atoms: " + elementId - }); - } else { + this.useAtomsElement(elementId, cb, _.bind(function(atomsElement) { this.remote.executeAtom('click', [atomsElement], cb); - } + }, this)); } else { var command = ["au.getElement('", elementId, "').tap()"].join(''); this.proxy(command, cb); diff --git a/sample-code/examples/node/safari.js b/sample-code/examples/node/safari.js index 7c7b097da..f44028654 100644 --- a/sample-code/examples/node/safari.js +++ b/sample-code/examples/node/safari.js @@ -32,8 +32,20 @@ browser should.not.exist(err); el.text(function(err, text) { text.should.eql("I am a div"); - browser.frame(null, function() { - browser.quit(); + browser.elementById('comments', function(err, comments) { + should.not.exist(err); + comments.sendKeys("This is an awesome comment", function() { + browser.elementById('submit', function(err, submit) { + submit.click(function() { + browser.elementById('your_comments', function(err, res) { + res.text(function(err, text) { + text.should.include("This is an awesome comment"); + browser.quit(); + }); + }); + }); + }); + }); }); }); });