undefined is not a function using UIATarget.localTarget()

103 views
Skip to first unread message

dave.b...@gmail.com

unread,
Oct 17, 2014, 3:24:30 PM10/17/14
to opa...@googlegroups.com
Hi,

I'm trying to use Opal and Native with UIAutomation / instruments to test iOS apps, but I'm having a bit of trouble getting Native wrapping to work. 

I did look through the documentation for Opal with the window example, but couldn't get it to work.

I'm creating a single javascript file called automation.js, in which I output the opal and native libraries:

File.open(script, 'w+') do |file|
   
['opal', 'native'].each do |library|
        file
<< Opal::Builder.build(library)
   
end
   
Dir["#{SRC}/**.rb"].each do |item|
        file
<< item.file_contents.to_js
   
end
end

Where to_js is a call to:

Opal.compile

At the moment, I have a single ruby file, with the following code:

automation.rb

UIATarget = Native(`UIATarget`)
UIATarget.localTarget().delay(5)

Which outputs the following JS file (I've removed the output from 'opal' and 'native') :

automation.js

/* Generated by Opal 0.6.2 */
(function($opal) {
 
var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice;


  $opal
.add_stubs(['$Native', '$delay', '$localTarget']);
  $opal
.cdecl($scope, 'UIATarget', self.$Native(UIATarget));
 
return $scope.UIATarget.$localTarget().$delay(5);
})(Opal);

But I get the following error:

2014-10-17 18:16:49 +0000 Error: Script threw an uncaught JavaScript error: undefined is not a function (evaluating '$scope.UIATarget.$localTarget()') on line 12228 of automation.js

But the call is valid JavaScript API for UIAutomation.

UIATarget.localTarget().delay(5)


I wondered if anyone knew why I was getting this error and if you could help me? Apologies if this is a newbie question, but I'm very interesting in seeing if I can use opalrb for UIAutomation testing.

Elia Schito

unread,
Oct 21, 2014, 4:07:05 AM10/21/14
to opa...@googlegroups.com
Hi, I discovered yesterday that calling properties with dots or square brackets is not the same for js automation objects (Eg. https://mobile.twitter.com/elia/status/524327328164225024)

I'll dig deeper and report back


Sent from Mailbox


--
You received this message because you are subscribed to the Google Groups "opalrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opalrb+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elia Schito

unread,
Nov 27, 2014, 6:58:29 PM11/27/14
to opa...@googlegroups.com
Didn’t have time so far and I don’t think I will in the near future, 
Nonetheless if anyone finds out anything please let us know :)


Elia

📢 twitter/elia 
☕️ github/elia
Reply all
Reply to author
Forward
0 new messages