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:
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.