/// <summary> /// Gets the DOM id of a node relative to this node, as defined by us. /// </summary> /// /// <remarks>The DOM id is the index of the given node in a depht-first search /// of the DOM tree. It is designed to give a good enough reference to a node /// that does not have an id attribute. This fails more or less depending on /// the amout of dynamic content inside the page.</remarks> /// <param name="root">Root element where to begin the search</param> /// <param name="node">Node to search for.</param> /// <returns>The DOM id of the node, or 0 if not found</returns> public static int GetDomId(this GeckoNode root, GeckoNode node) { int i = 0; foreach (var iter in root.TraverseDom ()) { i++; if (node.Equals (iter)) return i; } return 0; }