c# - Geckofx get xpath from geckoelement -


how can xpath geckoelement geckofx?

private void webbrowser_domclick(object sender, domeventargs e) {     geckoelement clickedelement = e.target.casttogeckoelement();                       } 

how clickedelement xpath?

    public static string getsmallxpath(this geckonode node)     {         if (node.nodetype == nodetype.attribute)         {              return string.format("{0}/@{1}", getsmallxpath(((geckoattribute)node).ownerdocument), node.localname);         }         if (node.parentnode == null)         {             return "";         }         string elementid = ((geckohtmlelement) node).id;         if (!string.isnullorempty(elementid))         {             return string.format("//*[@id=\"{0}\"]", elementid);          }           int indexinparent = 1;         geckonode siblingnode = node.previoussibling;          while (siblingnode != null)         {              if (siblingnode.localname == node.localname)             {                 indexinparent++;             }             siblingnode = siblingnode.previoussibling;         }           return string.format("{0}/{1}[{2}]", getsmallxpath(node.parentnode), node.localname, indexinparent);     }      public static string getxpath(this geckonode node)     {         if (node.nodetype == nodetype.attribute)         {              return string.format("{0}/@{1}", getxpath(((geckoattribute)node).ownerdocument), node.localname);         }         if (node.parentnode == null)         {              return "";         }           int indexinparent = 1;         geckonode siblingnode = node.previoussibling;          while (siblingnode != null)         {              if (siblingnode.localname == node.localname)             {                 indexinparent++;             }             siblingnode = siblingnode.previoussibling;         }          return string.format("{0}/{1}[{2}]", getxpath(node.parentnode), node.localname, indexinparent);     } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -