How to find all visible deeply nested ListView items? - qml

Im working on a squish based test and try to get decent (visible) items from a QML ListView that are deeply nested that i just can't pick due to its dynamic behavior
I've get the list itself by using waitForObject with a object map name
There are several nested items in the list an i want to get all occurrences of the MyTypeCCC_QMLTYPE_72 when property visible is true
I've dumped my current class/property child-hierachy:
MyTypeAAA_QMLTYPE_195
children[0] QQuickItem
children[0] QQuickColumn
children[0] MyTypeBBB_QMLTYPE_189
children[0] MyTypeCCC_QMLTYPE_7 visible(true)
I've found this in the Squish-KB: https://kb.froglogic.com/display/KB/Example+-+Finding+child+objects+by+type+and+property+values
so i can write my own search code traversing the tree etc. but i think that could(should) be an easier solution?
can i rely on the exact hierarchy? (but what i the UI design changed another time)
i could maybe add ids to the MyTypeCCC_... if that helps
I've got several of this list with different types/nesting and i hope to find a easy solution that works for all/many of the case
any ideas?

ListView is a subclass of Flickable and all its delegates are immediate children of ContentItem, you can safely iterate over its children to get all list items, but be aware that not all of its children are list delegates, so you have to filter them, e.g. by type. To find nested elements just search for them inside list item, i.e. use list item as a container. To create container locator you can use its coordinates (these are coordinates within the list, so they will be unique). Code may look like this:
list_view = findObject(list_locator)
nested = []
for i in range(list_view.contentItem.children.count):
item = list_view.contentItem.children.at(i)
if className(item) == 'MyTypeAAA':
netsed.append(findObject({'container': {'x': item.x, 'y': item.y, 'type': className(item)}, 'type': 'MyTypeCCC'}))

Related

How to find an item having same id by index from a list view

In XCTest, we could find a specific UI element by index, for instance, a list view has reused item with same identifier.
app.staticTexts.matching(identifier: "BETTER").element(boundBy: 1)
So, do we have an alternative method to find an element from a list view for Android UIautomator. I found this one could get element by id, but seems it only returns the first match.
mDevice.findObject(UiSelector().resourceId("id"))

Click on first element contained in a div

I have a div that contains a set of dynamic elements. I want to click on the first search result.
I want to click on the first element contains in
I tried using creating a custom xPath like so but it didn't work. Any ideas here?
//div[1][contains(text(), 'listing')]
First of all It would've helped if you had provided more information.
best will be using pseudo-child like div.firstChild or if the elements are generated dynamically you can add a class and use document.querySelectorAll(".class") which will give you an array of elements that had the class.
You can use array[0] to use click on the first element.
For anyone coming across this thread here is the solution
const listings = await page.$x('//*[contains(#id,"listing_")]')

how to get child properties of the div object for rational functinal tester

in my application i have a dropdown which is div object.the dropdown contain names and checkboxes.i need select the checkbox based on name. checkbox dont have any name.just index.can any one suggest how to get chaild items or properties of the objects for div object.
and the second question is i have tree view .which is teleric object.RFT is unable to find the object.it identifying as one all tree view is one object.its not identifying the childs,sub tree items....
so please help me on this two issues.
Hi you can get the checkboxes as follows:
void getCheckBoxes(TestObject parentDiv)
{
TestObject[] checkboxes = parentDiv.find(atDescendant(".class","Html.INPUT.checkbox"));
System.out.println("Found " + checkboxes.length);
//Go through them , and decide which one to select.
for(TestObject checkbox: checkboxes)
{
System.out.println("Checkbox Value: "+ checkbox.getProperty(".value"));
}
}
you can call the above method and pass it the parent DIV object.
About the second question:
You have not mentioed how does RFT recognize the one object for the tree ( means which proxy does it use as per the object map's adminitrative properties for that object).
Usually controls like tree /grid etc are recognized as one control and the items of these controls as "Subitem" which are found by specifying subitem as atPath("xyz->abc") etc.

Sencha Touch 2: Give a different itemTpl to nested list leaf nodes

In my nested list I have 2 levels. Currently it shows a standard list. When you click an item it takes you to a list of that item's children. Those children are the leaf nodes. So when you tap one of those it takes you to the detail card for that item. I'd like to use a different list item template for the children than the parent items. Is there a way to use Ext.XTemplate to check if an item is a leaf node or not?
Figured it out:
Simply update the x-list-item-leaf class
.x-list-item-leaf{
color:red !important;
}

libxml - looping through all children of a child

I am new to libxml. I would like to write 1 loop to loop through all the children of a child node etc. e.g.
<par>i want to <bold>loop <italic>through </italic> all</bold> children in this node</par>
At the moment my looping code look as follows but I only get the "bold" node and not the "italic" child.
if (xmlStrEqual(node->name, BAD_CAST "p")) {
xmlNodePtr child = node->children;
while (child != NULL) {
child = child->next;
}
}
It is conceivable that the node structure could grow to 4-5 elements, so I need a solution which is more robust that putting while loops within while loops. Any help would be appreciated please.
The xmlTree interface you're using is heirarchical. <par> has 3 children - the text before <bold>, <bold> itself, and the text after. <bold> has children of its own, which includes <italic>. The node->children list only contains the immediate children of a node.
There are a couple ways to get the behavior that you want.
While processing child, you can recursively process child->children to get to <bold>'s child, which includes <italics>
If you're looking SPECIFICALLY for that <itallic> (or for a set of specific nodes), you can use an XPath expression, such as "par//italic" to find any italic node anywhere beneath par.
http://www.xmlsoft.org/examples/index.html#XPath
You could look at libxml2's xmlTextReader interface rather than this xmlTree. It provides the serial "read through" of the document that you're expecting.
http://xmlsoft.org/xmlreader.html
Each method has its own advantages/disadvantages, depending on what all you're trying to do with your application.