Community
Participate
Working Groups
Created attachment 287764 [details] This is the result of the local debugging. It seems that the assumed iterator item time differs from the actual one. Code to reproduce the issue: ```java package io.appium.uiautomator2.utils; import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; import org.eclipse.wst.xml.xpath2.api.Item; import org.eclipse.wst.xml.xpath2.api.ResultSequence; import org.eclipse.wst.xml.xpath2.api.XPath2Expression; import org.eclipse.wst.xml.xpath2.processor.Engine; import org.eclipse.wst.xml.xpath2.processor.XPathParserException; import org.eclipse.wst.xml.xpath2.processor.util.DynamicContextBuilder; import org.eclipse.wst.xml.xpath2.processor.util.StaticContextBuilder; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.SAXException; import static org.junit.Assert.assertEquals; import android.os.SystemClock; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import io.appium.uiautomator2.common.exceptions.InvalidSelectorException; public class XMLHelpersTests { private static Document loadDocument(String str) { DocumentBuilderFactory factory = new DocumentBuilderFactoryImpl(); factory.setNamespaceAware(true); factory.setValidating(false); try (InputStream in = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8))) { return factory.newDocumentBuilder().parse(in); } catch (SAXException | ParserConfigurationException | IOException e) { throw new RuntimeException(e); } } private static List<Node> findNodes(String xml, String xpathSelector, boolean multiple) { StaticContextBuilder scb = new StaticContextBuilder(); final XPath2Expression expr; try { expr = new Engine().parseExpression(xpathSelector, scb); } catch (XPathParserException e) { throw new InvalidSelectorException(e); } try { Document doc = loadDocument(xml); ResultSequence rs = expr.evaluate(new DynamicContextBuilder(scb), new Object[] { doc }); Iterator<Item> iterator = rs.iterator(); List<Node> result = new ArrayList<>(); final long timeStarted = SystemClock.uptimeMillis(); while (iterator.hasNext()) { Item item = iterator.next(); if (!(item.getNativeValue() instanceof Node)) { continue; } Node node = (Node) item.getNativeValue(); if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } result.add(node); if (!multiple) { break; } } Logger.info(String.format("Took %sms to retrieve %s matches for '%s' XPath query", SystemClock.uptimeMillis() - timeStarted, result.size(), xpathSelector)); return result; } catch (Exception e) { throw new RuntimeException(e); } } @Test public void parsesComplexXpath1() { String document = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\n" + "<hierarchy index=\"0\" class=\"hierarchy\" rotation=\"0\" width=\"1080\" height=\"1794\">\n" + " <android.widget.FrameLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.FrameLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,0][1080,1794]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,0][1080,1794]\" displayed=\"true\">\n" + " <android.widget.FrameLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.FrameLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,1794]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/action_bar_root\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,1794]\" displayed=\"true\">\n" + " <android.widget.FrameLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.FrameLayout\" text=\"\" resource-id=\"android:id/content\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,1794]\" displayed=\"true\">\n" + " <android.widget.FrameLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.FrameLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,1794]\" displayed=\"true\">\n" + " <androidx.drawerlayout.widget.DrawerLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"androidx.drawerlayout.widget.DrawerLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/drawer_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,1794]\" displayed=\"true\">\n" + " <android.view.ViewGroup index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.view.ViewGroup\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/toolbar_coordinator_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,1794]\" displayed=\"true\">\n" + " <android.view.ViewGroup index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.view.ViewGroup\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/toolbar\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][1080,210]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"Navigate up\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,63][147,210]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"OFFLINE MAPS\" resource-id=\"com.abcde.pqrst.gamma:id/toolbar_title\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[353,110][727,162]\" displayed=\"true\" />\n" + " </android.view.ViewGroup>\n" + " <android.widget.LinearLayout index=\"2\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,210][1080,1794]\" displayed=\"true\">\n" + " <android.widget.FrameLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.FrameLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/activity_frame_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,210][1080,1794]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,210][1080,1794]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Download settings\" resource-id=\"com.abcde.pqrst.gamma:id/offline_management_settings_header\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,210][1080,334]\" displayed=\"true\" />\n" + " <android.view.View index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.view.View\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/offline_divider_1\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,334][1080,337]\" displayed=\"true\" />\n" + " <android.view.ViewGroup index=\"2\" package=\"com.abcde.pqrst.gamma\" class=\"android.view.ViewGroup\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,337][1080,589]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,337][932,589]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Allow downloads over cell network\" resource-id=\"com.abcde.pqrst.gamma:id/offline_list_network_switch_title\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,379][890,455]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"If Wi-Fi isn't available, your maps will use your cell data to download updates.\" resource-id=\"com.abcde.pqrst.gamma:id/offline_list_network_switch_message\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,455][890,547]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.Switch index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.Switch\" text=\"OFF\" content-desc=\"offline_list_network_switch\" resource-id=\"com.abcde.pqrst.gamma:id/offline_list_network_switch\" checkable=\"true\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[932,337][1080,471]\" displayed=\"true\" />\n" + " </android.view.ViewGroup>\n" + " <android.view.View index=\"3\" package=\"com.abcde.pqrst.gamma\" class=\"android.view.View\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/offline_divider_2\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,589][1080,592]\" displayed=\"true\" />\n" + " <androidx.recyclerview.widget.RecyclerView index=\"4\" package=\"com.abcde.pqrst.gamma\" class=\"androidx.recyclerview.widget.RecyclerView\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/recycler_view\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"true\" focused=\"true\" long-clickable=\"false\" password=\"false\" scrollable=\"true\" selected=\"false\" bounds=\"[0,592][1080,1794]\" displayed=\"true\">\n" + " <android.widget.RelativeLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 2\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,592][1080,674]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,592][933,674]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"72 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,592][933,641]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,592][1038,674]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,592][1038,634]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " <android.widget.RelativeLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 3\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,677][1080,861]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,677][933,861]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Ann Arbor, MI\" resource-id=\"com.abcde.pqrst.gamma:id/region_name\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,709][933,769]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"151 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,775][933,828]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,677][1038,861]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,716][1038,821]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " <android.widget.RelativeLayout index=\"2\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 4\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,864][1080,1048]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,864][933,1048]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Asheville, NC\" resource-id=\"com.abcde.pqrst.gamma:id/region_name\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,896][933,956]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"88 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,962][933,1015]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,864][1038,1048]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,903][1038,1008]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " <android.widget.RelativeLayout index=\"3\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 5\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,1051][1080,1235]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1051][933,1235]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Atlanta, GA\" resource-id=\"com.abcde.pqrst.gamma:id/region_name\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1083][933,1143]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"669 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1149][933,1202]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1051][1038,1235]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1090][1038,1195]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " <android.widget.RelativeLayout index=\"4\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 6\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,1238][1080,1422]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1238][933,1422]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"some, text\" resource-id=\"com.abcde.pqrst.gamma:id/region_name\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1270][933,1330]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"244 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1336][933,1389]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1238][1038,1422]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1277][1038,1382]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " <android.widget.RelativeLayout index=\"5\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 7\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,1425][1080,1609]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1425][933,1609]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Basalt, CO\" resource-id=\"com.abcde.pqrst.gamma:id/region_name\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1457][933,1517]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"14 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1523][933,1576]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1425][1038,1609]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1464][1038,1569]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " <android.widget.RelativeLayout index=\"6\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.RelativeLayout\" text=\"\" content-desc=\"Region Cell 8\" resource-id=\"com.abcde.pqrst.gamma:id/region_cell_layout\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[0,1612][1080,1794]\" displayed=\"true\">\n" + " <android.widget.LinearLayout index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_descriptor_layout\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1612][933,1794]\" displayed=\"true\">\n" + " <android.widget.TextView index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"Baton Rouge, LA\" resource-id=\"com.abcde.pqrst.gamma:id/region_name\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1644][933,1704]\" displayed=\"true\" />\n" + " <android.widget.TextView index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.TextView\" text=\"97 MB\" resource-id=\"com.abcde.pqrst.gamma:id/region_subtext\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[42,1710][933,1763]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " <android.widget.LinearLayout index=\"1\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.LinearLayout\" text=\"\" resource-id=\"com.abcde.pqrst.gamma:id/region_button_holder\" checkable=\"false\" checked=\"false\" clickable=\"false\" enabled=\"true\" focusable=\"false\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1612][1038,1794]\" displayed=\"true\">\n" + " <android.widget.ImageButton index=\"0\" package=\"com.abcde.pqrst.gamma\" class=\"android.widget.ImageButton\" text=\"\" content-desc=\"region_download\" resource-id=\"com.abcde.pqrst.gamma:id/region_download\" checkable=\"false\" checked=\"false\" clickable=\"true\" enabled=\"true\" focusable=\"true\" focused=\"false\" long-clickable=\"false\" password=\"false\" scrollable=\"false\" selected=\"false\" bounds=\"[933,1651][1038,1756]\" displayed=\"true\" />\n" + " </android.widget.LinearLayout>\n" + " </android.widget.RelativeLayout>\n" + " </androidx.recyclerview.widget.RecyclerView>\n" + " </android.widget.LinearLayout>\n" + " </android.widget.FrameLayout>\n" + " </android.widget.LinearLayout>\n" + " </android.view.ViewGroup>\n" + " </androidx.drawerlayout.widget.DrawerLayout>\n" + " </android.widget.FrameLayout>\n" + " </android.widget.FrameLayout>\n" + " </android.widget.LinearLayout>\n" + " </android.widget.FrameLayout>\n" + " </android.widget.LinearLayout>\n" + " </android.widget.FrameLayout>\n" + "</hierarchy>"; // String query = "(//android.widget.TextView[@text='some, text']/following::android.widget.ImageButton)[1]"; String query = "//android.widget.TextView[@text='some, text']/preceding::*"; List<Node> nodes = findNodes(document, query, false); assertEquals(nodes.size(), 1); } } ``` Basically all queries containing either preceding or following axis fail with the same ``` java.lang.ClassCastException: class java.util.ArrayList$ListItr cannot be cast to class org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType (java.util.ArrayList$ListItr is in module java.base of loader 'bootstrap'; org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType is in unnamed module of loader 'app') java.lang.RuntimeException: java.lang.ClassCastException: class java.util.ArrayList$ListItr cannot be cast to class org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType (java.util.ArrayList$ListItr is in module java.base of loader 'bootstrap'; org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType is in unnamed module of loader 'app') at io.appium.uiautomator2.utils.XMLHelpersTests.findNodes(XMLHelpersTests.java:98) at io.appium.uiautomator2.utils.XMLHelpersTests.parsesComplexXpath1(XMLHelpersTests.java:230) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:121) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.lang.ClassCastException: class java.util.ArrayList$ListItr cannot be cast to class org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType (java.util.ArrayList$ListItr is in module java.base of loader 'bootstrap'; org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType is in unnamed module of loader 'app') at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:63) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.internal.PrecedingAxis.iterate(PrecedingAxis.java:52) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1357) at org.eclipse.wst.xml.xpath2.processor.internal.ast.ReverseStep.accept(ReverseStep.java:102) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:2077) at org.eclipse.wst.xml.xpath2.processor.internal.ast.AxisStep.accept(AxisStep.java:47) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_step(DefaultEvaluator.java:1113) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:1251) at org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr.accept(XPathExpr.java:45) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.do_expr(DefaultEvaluator.java:339) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.visit(DefaultEvaluator.java:368) at org.eclipse.wst.xml.xpath2.processor.ast.XPath.accept(XPath.java:60) at org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator.evaluate2(DefaultEvaluator.java:327) at org.eclipse.wst.xml.xpath2.processor.ast.XPath.evaluate(XPath.java:133) at io.appium.uiautomator2.utils.XMLHelpersTests.findNodes(XMLHelpersTests.java:75) ... 48 more ``` error upon executing `evaluate` on the given document. The version of the used processor lib is org.eclipse.wst.xml.xpath2.processor_2.1.101.v201903222120.jar (downloaded from the official Eclipse page)
I'm still seeing this behavior, too. Also, given the naming of the packages referenced in the error logs, is it possible that this belongs in another Product or Component category? Like, Product = WTP Common Tools and/or Component = wst.common? Just trying to think of ways to increase visibility to this bug, is all.
(In reply to Robert Kloster from comment #1) > I'm still seeing this behavior, too. Also, given the naming of the packages > referenced in the error logs, is it possible that this belongs in another > Product or Component category? Like, Product = WTP Common Tools and/or > Component = wst.common? Just trying to think of ways to increase visibility > to this bug, is all. It's possible that is is a bug in WTP Source Editing. If you're still seeing this in 2022-12, you could create a WTP bug in this bugzilla. I'm not sure if the platform project is still triaging bugs here. Their development has moved to GitHub at https://github.com/eclipse-platform .