{"id":4386,"date":"2014-03-30T10:24:38","date_gmt":"2014-03-30T10:24:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-ios-ui-automation-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:24:38","modified_gmt":"2014-03-30T10:24:38","slug":"problem-about-ios-ui-automation-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-ios-ui-automation-collection-of-common-programming-errors\/","title":{"rendered":"problem about ios-ui-automation-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc18a7074ca1d3f16d35f1a86c3a87c1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnschum<br \/>\niphone ios4 sdk ios-ui-automation<br \/>\nI am new to iPhone Automation, and UIAutomation framework introduced by iOS4. Recently I am using UIAutomation to automate testing app on iPhone Simulator via instruments but it gives me an error like &#8220;Unexpected error in -[UIATarget_0x5a20d20 frontMostApp], \/SourceCache\/UIAutomation_Sim\/UIAutomation-37\/Framework\/UIATargetElements.m line 437&#8243;I have also tried it by running app on the iPhone 3G device after updating it with iOS4. But the instrument shows me the warning &#8220;Automation is not supporte<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/37818357a4e08938badb1f321c0654a6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ndtuckernet<br \/>\niphone ios ios-simulator ui-automation ios-ui-automation<br \/>\nI&#8217;ve been using the new UI automation tools with Instruments and the iPhone SDK 4.0, but so far I haven&#8217;t been able to get it to run under the iPhone Simulator. I&#8217;ve tried setting the target to every location possible-my build folder, the app folder in ~\/Library\/Application Support\/iPhone Simulator, etc.-but I get an error message when I try to run it:Unexpected error in -[UIATarget_0x5a1e3b0 frontMostApp], \/SourceCache\/UIAutomation_Sim\/UIAutomation-37\/Framework\/UIATargetElements.m line 437,Has<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc18a7074ca1d3f16d35f1a86c3a87c1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnschum<br \/>\niphone ios4 instruments ios-ui-automation<br \/>\nI am currently using IOS SDK 4.0.2 and learning how to do UIAutomation. Unfortunately I found that in the Simulator, when I try running a simple Java script test (that just assigns variables) I get the following error.Unexpected error in -[UIATarget_0x5d04f60 frontMostApp], \/SourceCache\/UIAutomation_Sim\/UIAutomation-37\/Framework\/UIATargetElements.m line 437,Here is the &#8220;Script&#8221; I was trying to runfunction iDontDoAnything() {var target = UIATarget.localTarget();var app = target.frontMostApp();var<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc18a7074ca1d3f16d35f1a86c3a87c1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnschum<br \/>\nios accessibility ios-ui-automation<br \/>\nI can only set Accessibility Label in interface builder, but in UI Automation,I need Accessibility Identifier to get the UI elements. any way to do this?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9a174a1c104593989507de16c8bb769?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntech_learning<br \/>\nobjective-c xcode4.5 ios-ui-automation<br \/>\nI have a xib file which has a view. Under a view, I have few labels&#8230; I am working on UIAutomation and hence want to add accessibility identifiers to the view and each of these labels. How can I do it inside the xib? I googled and found that a field named &#8220;identifier&#8221; should be used&#8230; but I cannot see any suck field for view and label.Please suggest.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9a174a1c104593989507de16c8bb769?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntech_learning<br \/>\nobjective-c arrays ios6 ios-ui-automation<br \/>\nI am dealing with UIAElementArray for the ios automation and looking for an easier way to search inside the UIAElementArray.Below is the code:var textArray = this.myCollectionViews.staticTexts();textArray.toArray() \/\/ Trying to convert UIAElementArray to a javascript array.logger.logDebug(&#8216;Array object is&#8217; + textArray); \/\/ Here the output is [object UIAElementArray]; which I guess should be Array and not UIAElementArray.if (textArray.indexOf(&#8216;Hello&#8217;) &gt; -1) {\/\/ do this }Here I am getting a cr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/52a2ffb44b1c11ab9001cb67e0a0021c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBrad Larson<br \/>\nios instruments ios-ui-automation xcode-instruments<br \/>\nWhen I try to run a UI Automation script on iOS 5 devices I am getting the following error:&#8221;An error occurred while trying to run the script.&#8221;The same script is running perfectly in the simulator or on an iOS 4.3.3 device.How can I solve this problem?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5a1a8df9589642533346195587da52c3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser293895<br \/>\nios ios-ui-automation<br \/>\nI have an app that I am trying to automatically debug using a shotgun approach (randomly touching the app for a long period of time). I am currently using UIAutomation and this script:var target = UIATarget.localTarget(); var app = target.frontMostApp(); var window = app.mainWindow();target.delay(2);window.tapWithOptions( { x:160.0, y:370.0 } );target.delay(5);for(i=0;i&lt;=100000;i++) {xPoint = Math.floor(Math.random()*319+1)yPoint = Math.floor(Math.random()*479+1)window.tapWithOptions( { x:xPo<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc18a7074ca1d3f16d35f1a86c3a87c1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnschum<br \/>\niphone ios testing ui-automation ios-ui-automation<br \/>\nI have had some strange, hard to reproduce crashes, when testing my app with an ad-hoc version on my iPhone. The crashes happened after changing from my app to the dashboard (or other app) and then changing back to the app again.Is there a way to use UIAutomation in a way to perform these changes automatically?Thanks in advance.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4e14637cc7abaac31d18932d031399b6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRobEarl<br \/>\ncocos2d-iphone bdd ios-ui-automation zucchini<br \/>\nIs it possible to use UIAutomation with cocos2d or any opengl application for that matter?Specifically I want to use the zucchini framework to test my cocos2d game but that just uses UIAutomation anyway.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/381d907ee02599bd346c06c447e3ebf0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nfogwolf<br \/>\nios ui-automation ios-ui-automation<br \/>\nI think this is a first &#8211; I&#8217;m getting an error and the exception constant that I&#8217;m getting back returns nothing when I search for it on Google.Basically I&#8217;m trying to run UI Automation on my iOS app from the CLI and am getting the following error message:2013-02-22 13:12:17.820 ScriptAgent[16626:2e07] +[UIAXElement initialize]: UIAutomation never received kAXAccessibilityLoaded. Waited 20.02 seconds.2013-02-22 13:12:17.826 ScriptAgent[16626:2e07] Unexpected error in -[UIAXElement_0xad343c initi<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/746cfbfb116ad542c6317f1ffd748ba7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nc roald<br \/>\nios-ui-automation<br \/>\nI&#8217;m trying to break up my UIAutomation test scripts into chunks, to make it possible to run them one piece at a time or all together. So I have a structure:all-tests.js:#import &#8220;tab-dates.js&#8221; #import &#8220;tab-temperatures.js&#8221;tab-dates.js:#import &#8220;..\/..\/..\/Libraries\/tuneup_js\/tuneup.js&#8221; #import &#8220;dpl_assertions.js&#8221;var target = UIATarget.localTarget(); var app = target.frontMostApp();test(&#8220;Verify date view is shown&#8221;, function() {assertEquals(tabBar.selectedButton().name(), &#8220;Date&#8221;); });Both of these li<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a8ad258fc01551811773af6bb31a915f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ncodemau5<br \/>\nui-automation ios-ui-automation<br \/>\nFor this line of test code : view.scrollViews()[0].tapWithOptions({tapOffset:{x:0.32, y:0.25}})I am getting this error 2012-11-02 18:09:23 +0000 None: Script threw an uncaught JavaScript error: target.frontMostApp().mainWindow().scrollViews()[0] could not be tapped on line 244 of feature.js 2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scrollViews()[0].tapWithOptions({tapOffset:{x:&#8221;0.32&#8243;, y:&#8221;0.25&#8243;}}) 2012-11-02 18:09:23 +0000 Debug: target.frontMostApp().mainWindow().scroll<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/88f91aa371ee0172fe91088cbf8b0427?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njohngraham<br \/>\njavascript ios scope integration-testing ios-ui-automation<br \/>\nI&#8217;ve set up some UIAutomation scripts that will eventually become jenkins tests. The UIAutomation scripts do not output in jenkins-friendly format, so I&#8217;m using tuneup_js, specifically this failure exception.When a test fails, I can throw a custom FailureException. The exception is gracefully caught and failure output is properly logged. The output is Error: FailureException: &#8220;hello world&#8221;.My problem occurs when I try to throw that same FailureException inside an onAlert handler, UIATarget.onAle<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b97c588b0bae345d620969b065c36e56?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nralphbert<br \/>\nios-ui-automation ui-testing ios6.1<br \/>\nI just want to test my iOS UI with UI Automation but I got stuck when it comes to enter text into UITextFields. The documentation says that the method &#8220;setValue(&#8230;)&#8221; should do the trick but it doesn&#8217;t.I always get this error:Script threw an uncaught JavaScript error: Unexpected error in -[UIATextField_0x9952690 setValue:], \/SourceCache\/UIAutomation_Sim\/UIAutomation-271\/Framework\/UIAElement.m line 1142, kAXErrorSuccess on line 15 of login.js, #0 setValue() The code looks like this:var textfields<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f826559f060105ab62a09e263500cba7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1060816<br \/>\nios ios-ui-automation<br \/>\nI&#8217;m working on my first UI Automation script and am encountering a failure at the deactivateAppForDuration line below:\/\/ Verify password field is shown when app is moved to the foreground UIALogger.logMessage(&#8220;move app to background&#8221;); target.deactivateAppForDuration(10); UIALogger.logMessage(&#8220;move app to foreground&#8221;);The error I get from Instruments is:Script threw an uncaught JavaScript error: Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().switcherScrollView<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/29edd620dc6b0def09cbc1bbb046b836?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbollhav<br \/>\nios-ui-automation<br \/>\nI&#8217;m trying to automate keyboard typing with UI Automation.target.frontMostApp().keyboard().typeString(&#8220;INTERCOM&#8221;)But i will get this error after first &#8216;I&#8217; is typedtarget.frontMostApp().keyboard() failed to locate key &#8216;N&#8217; Script threw an uncaught JavaScript error: target.frontMostApp().keyboard() failed to locate key &#8216;N&#8217;I have a localized swedish keyboard.Anyone know if this a bug or something I&#8217;ve missed?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3f0bcd40079e38e504dcaed58cfa29f3?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJack<br \/>\njavascript ios-ui-automation<br \/>\nScript threw an uncaught JavaScript error:Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().popover().actionSheet().buttons()[&#8220;Save Note&#8221;]Code:var target = UIATarget.localTarget(); var app = target.frontMostApp(); var window = app.mainWindow(); target.logElementTree(); UIALogger.logPass(&#8220;Stick Note Save Start&#8221;); app.navigationBar().toolbar().buttons()[&#8220;Plus&#8221;].tap(); app.keyboard().typeString(&#8220;Ki&#8221;); window.popover().actionSheet().buttons()[&#8220;Save Not<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ce11e40d3bc97ffb2c8d86184443d009?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmarmor<br \/>\nios uiscrollview ios-ui-automation uicollectionview<br \/>\nI&#8217;m trying to write a test script using automation in xcode 4.5.I have a UICollectionView and I want to click on some cell not currently visible.Per documentation, I should expect cells to return all cells in the collection view, and visibleCells to return only the currently visible ones.Instead what I&#8217;m seeing is that cells returns only the currently visible cells, and calling visibleCells stops the script on &#8216;undefined&#8217; is not a function (evaluating &#8216;collection.visibleCells()&#8217;)var target = UIA<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/54f9334b0f947121db80f8b4356fab30?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOrtwin Gentz<br \/>\niphone ios instruments ui-automation ios-ui-automation<br \/>\nI tried the tapAndHold() function from UIAElementvar target = UIATarget.localTarget(); target.frontMostApp().mainWindow().buttons()[&#8220;Button&#8221;].tapAndHold() target.captureScreenWithName(&#8220;shot&#8221;)but this fails with a JavaScript error: &#8216;undefined&#8217; is not a function (evaluating target.frontMostApp().mainWindow().buttons()[&#8220;Button&#8221;].tapAndHold().Update:I also triedtarget.frontMostApp().mainWindow().buttons()[&#8220;Button&#8221;].touchAndHold(1.5) target.captureScreenWithName(&#8220;shot&#8221;)which at least does highlight t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b9a174a1c104593989507de16c8bb769?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ntech_learning<br \/>\njavascript ios ios-ui-automation uiaccessibility<br \/>\nI have added an accessibility identifier to a label so that I can use it in my UIAutomation javascript files. How do I access the text on the label using accessibility identifier?Suppose &#8220;aLabel&#8221; is the accessibility identifier and my javascript function to access the text on that label is:appLabelValue:function() { return this.getElement(&#8216;aLabel&#8217;).value(); }I even tried replacing .value() with .text() in the above method but I am getting same error for both i.e. undefined is not a function.Plea<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/57737bc1df617937af015ab27c4a5722?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nsatyajit<br \/>\njavascript ios node.js npm ios-ui-automation<br \/>\nAccording to apple&#8217;s documentation I can import one JS file into another with an import statement. And yes I am able to use JS functions and recursively call other JS functions.But can I include node modules into my automation. Node\/npm module seems to have a lot of tools that makes life easier and avoid code duplication.And actually I was able to use one node module called moment.js through the following call in my code #import &#8220;..\/node_modules\/moment\/moment.js&#8221;But I am not have the same luck w<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>nschum iphone ios4 sdk ios-ui-automation I am new to iPhone Automation, and UIAutomation framework introduced by iOS4. Recently I am using UIAutomation to automate testing app on iPhone Simulator via instruments but it gives me an error like &#8220;Unexpected error in -[UIATarget_0x5a20d20 frontMostApp], \/SourceCache\/UIAutomation_Sim\/UIAutomation-37\/Framework\/UIATargetElements.m line 437&#8243;I have also tried it by running app on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4386","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4386"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4386\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}