How to access children of mainWindow for UI Automation in Xcode - ios

I have a structure in the mainWindow() of my application as follows:
Within the children directory of the UIAWindow near the top of the image, I am trying to access Item 1, where it is a UIAButton.
This structure is generated from
#import "tuneup/tuneup.js"
goAbout = function(target, app)
{
UIATarget.localTarget().frontMostApp().mainWindow().logElementTree();
};
test("go about", goAbout);
If I add .button() or [1] it raises an exception, so I cannot do something like so
...
UIATarget.localTarget().frontMostApp().mainWindow().buttons().logElementTree();
What can I do to access the object within the children subdirectory of the UIAWindow?

You can access that button by adding .buttons()[0]. The
UIATarget.localTarget().frontMostApp().mainWindow().buttons();
expression returns a javascript array (which has a 0 based indexing).
Here you can find a rather usable documentation:
https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/UIAutomationRef.pdf
Anyway studying this plist is not the most convenient method to explore your object hierarchy. I prefer to check instruments output directy. (Or standard output, if you run instruments from command line.)

That tree hierarchy ended up not meaning anything useful to me, and I ended up utilizing target methods to access the elements of my window. Cheers!

Related

DXL: Copy Objects from one closed module to a second closed module

I'm trying to create a DXL script that will take all the objects from select set of modules and combine them into a new module which will then be exported to Excel.
The issue I'm having is I can't figure out how to get objects from a module that isn't open. I'm open to any method but I've been trying to use ModuleHandles. Most of the examples I've seen are for moving objects within the current module.
You need two variables of type Module, one for the source module (e.g. mSrc), one for the target module (mTgt). Use the command read for opening the source module and setting the resulting handle to mSrc. Use edit (or create) for opening the target module and setting the resulting handle to mTgt.
Then use a variable of type Object for iterating over all objects of mSrc (for oSrc in mSrc or perhaps ... in entire mSrc, depending on how the views in your source modules are set up), create objects in the target module (to a variable oTgt of type Object) copy the object attributes that you need from oSrc to oTgt. For the latter there is a function copyAttribute_ in copyops.inc.
If you want to replicate the hierarchy of the source module, you will need loops of type for Object in Object and commands like create after create below etc.
Perhaps there are already scripts available in IBMs DXL Forum or on some of the web sites that provide a solution for your problem.

Binding imperatively

Is there a way to set up bindings imperatively. An example use case:
var el2 = new MyElement();
el2.myProp = this.$.anotherElement.anotherProp
That won't setup a binding, it just assigns the value or object. I'd like to find a way to do something like:
el2.myProp.bindTo(this.$.anotherElement.anotherProp)
Possible?
Polymer 1.0 does not support this at the moment - as explained by #kevinpschaaf in Github https://github.com/Polymer/polymer/issues/1778.
(comment by #kevinpschaaf)
No, we don't currently support this, outside of dom-bind, which is the
only template implementation that late-binds instance children. You
can document.createElement('template', 'dom-bind'), then you can
dynamically append children with binding annotations to its content,
and the bindings will only be evaluated once the dom-bind is attached
to the document. See tests here that show this usage of it:
https://github.com/Polymer/polymer/blob/master/test/unit/dom-bind.html#L95
Note that dom-bind does not currently allow binding to outer scope, so
it has limited use in custom element templates (it's main use case is
for binding between elements in the main document), and that's not
likely to change short-term.
We are achieving a lot of performance optimization by baking the
binding connections into the prototype at registration time for an
element (rather than at instance time), and we haven't built up enough
of the machinery to easily allow runtime addition/removal of bindings.

If I have applied a fixed window, will I always get an IntervalWindow from `window()`

If I implement a DoFn with access to the window, with the sidecondition that PCollection being transformed has already had some non-global windowing strategy applied to it, i.e. FixedWidows am I guaranteed to get an IntervalWindow?
For FixedWindows, yes. In general, no. The only general guarantee is that you'll get a BoundedWindow. Currently, all of the non-global windows provided by the SDK (FixedWindows, SlidingWindows, Sessions) use IntervalWindows. But it's perfectly legal to have a non-global windowing strategy that uses only BoundedWindows.
Yes. The window() method returns whatever kind of window the current WindowFn has placed the element into. So, with FixedWindows this will always return an IntervalWindow.
It will also always return a single window. So if you're using SlidingWindows and each element is placed into 5 different windows, then the processElement() of a DoFn annotated with RequiresWindowAccess will be called once for each window the element is placed into (so 5 times for each element).

TiViewProxy and view creation

I'm working on a titanium module.
Little bit confused about the TiViewProxy.
Why we are using -(void)setColor_:(id)color such methods (_ in methods) in ViewProxy ?
If we didn't write any such methods what happens when we call:
myModule.createView({
color : 'red'
});
If I didn't passed any argument on my createView() method how my view creation code will work on my module.
Means:
I'm just creating my view in my app.js like:
myModule.createView();
I'm handling the view creation code inside:
-(void)setColor_:(id)color
{
}
If I'm not passing any argument how my view is created ? Will it work ?
I'll explain the various moving parts. It's all part of the platform, so not critical that you know how it works. Knowing that it does this for you is important, though. So...
When you call myModule.createView(), the platform looks for a child of your module that matches certain constraints. Let me expand that statement by looking at the ti.pageflip module. myModule's class is TiPageflipModule. When I call myModule.createView(), the platform will look for TiPageflipViewProxy so it can instantiate it. TiPageflip comes from the module's name, minus "Module". "View" comes from createView. "Proxy" is tagged on because that's how we get from JavaScript to native. The TiPageflipViewProxy creates a native view, TiPageflipView. The proxy handles interactions between JavaScript and the native view. Make sense so far?
Part of the naming convention for exposed properties is that they are suffixed with an _. The platform looks for these methods, and calls each of them set in the creation dictionary createView({ whatever: 'value' }) as well as the property view.whatever = 'value'; or the method view.setWhatever('value'). (Search for the word "underscore" in the iOS mod dev guide, it only occurs once, to read more: https://wiki.appcelerator.org/display/guides/iOS+Module+Development+Guide).
Because you aren't defining createView, the platform is doing it for you, and it handles createView() just the same as createView({}). It's an optional param. That's just by definition.

web service code in actionscript

im calling an actionscript class from my main mxml file. the actionscript class is responsible for calling a web service and handling the response, however im having trouble and keep getting the following error; (im new to flex btw)
Error #1009: Cannot access a property or method of a null object reference.
my code goes as follows;
public function getSites(argWsdl:String):void{
ws = new WebService();
ws.loadWSDL(argWsdl);
ws.getSites.addEventListener(ResultEvent.RESULT,echoResultHandler);
ws.getSites();
}
public function echoResultHandler(event:ResultEvent):void {
var siteField:ArrayCollection = event.result as ArrayCollection;
Application.application.setSiteField(siteField);
}
when i run the debugger the code never reaches the result hanlder and i see the #1009 error in the variable list.
any ideas?
looks like you have it sorted, but just to add more information in case someone else comes along to this question, you generally see this error when you are trying to use something that hasn't been created yet. A lot of the time you will see it when trying to access UI components that have not yet been created (its good to rely on the creationComplete event for these sort of things), but in this case it looks like you are using the webservice before it is completely ready (the wsdl hasnt been loaded yet).
Just so you know, you can also define your webservices in mxml (mx:webservice) and specify the wsdl there or you can also load the wsdl later on from a configuration file afterwards just by referencing the ID.
sorted it out,
i needed to created a loadEvent and loadhandler. Once loadWsdl is called the loadhandler specifies the laodHandler to use, inside the loadHandler i call the method name as seen in the wsdl
thanks Ryan,
the main reason im using a seperate actionscript class is so i can reuse the same web service calls across my components without having to retype the same code. I couldnt think of a better way to do this - maybe a could have done the same with a custom component

Resources