/** * Evaluates the specified XPath expression from this node, returning the first matching element, * or {@code null} if no node matches the specified XPath expression. * * @param xpathExpr the XPath expression * @param <X> the expression type * @return the first element matching the specified XPath expression * @see #getByXPath(String) * @see #getCanonicalXPath() */ public <X> X getFirstByXPath(final String xpathExpr) { return getFirstByXPath(xpathExpr, null); }
public <X> X selectSingleNode(final String xpathExpr) { return this.<X>getFirstByXPath(xpathExpr); }
public static Node findByClass(String c, DomNode h) { return h.getFirstByXPath("//*[@class='" + c + "']"); }
public static Node findById(String c, DomNode h) { return h.getFirstByXPath("//*[@id='" + c + "']"); }
public static Node findByType(String c, DomNode h) { return h.getFirstByXPath("//*[@type='" + c + "']"); }
/** * Evaluates the specified XPath expression from this node, returning the first matching element, * or {@code null} if no node matches the specified XPath expression. * * @param xpathExpr the XPath expression * @param <X> the expression type * @return the first element matching the specified XPath expression * @see #getByXPath(String) * @see #getCanonicalXPath() */ public <X> X getFirstByXPath(final String xpathExpr) { return getFirstByXPath(xpathExpr, null); }
private HtmlElement getHtmlElementByXPath(DomNode parent, String xpath) { return (HtmlElement) parent.getFirstByXPath(xpath); }
public Object selectSingleNode(final String xpathExpr) { return getFirstByXPath(xpathExpr); }
public static Node findByName(String c, DomNode h) { return h.getFirstByXPath("//*[@name='" + c + "']"); }
public void assertXPathValueContains(DomNode page, String xpath, String needle) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertTrue("needle found in haystack", textString.contains(needle)); }
public void assertXPathValueContains(DomNode page, String xpath, String needle) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertTrue("needle found in haystack", textString.contains(needle)); }
public void assertXPathValueContains(DomNode page, String xpath, String needle) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertTrue("needle found in haystack", textString.contains(needle)); }
public void assertXPathValueContains(DomNode page, String xpath, String needle) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertTrue("needle found in haystack", textString.contains(needle)); }
public void assertXPathValueContains(DomNode page, String xpath, String needle) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertTrue("needle found in haystack", textString.contains(needle)); }
public void assertXPathValue(DomNode page, String xpath, String expectedValue) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertEquals("xpath value should match for " + xpath, expectedValue, textString); }
public void assertXPathValue(DomNode page, String xpath, String expectedValue) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertEquals("xpath value should match for " + xpath, expectedValue, textString); }
public void assertXPathValue(DomNode page, String xpath, String expectedValue) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertEquals("xpath value should match for " + xpath, expectedValue, textString); }
public void assertXPathValue(DomNode page, String xpath, String expectedValue) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertEquals("xpath value should match for " + xpath, expectedValue, textString); }
public void assertXPathValue(DomNode page, String xpath, String expectedValue) { Object node = page.getFirstByXPath(xpath); assertNotNull("no node found", node); assertTrue("the found object was not a Node " + xpath, node instanceof org.w3c.dom.Node); org.w3c.dom.Node n = (org.w3c.dom.Node) node; String textString = n.getTextContent(); assertEquals("xpath value should match for " + xpath, expectedValue, textString); }
/** * Evaluates the specified XPath expression from this node, returning the first matching element, * or <tt>null</tt> if no node matches the specified XPath expression. * <p> * Calls {@link WebClientUtil#waitForJSExec(com.gargoylesoftware.htmlunit.WebClient)} before * executing the query. * * @param domNode the node to start searching from * @param xpathExpr the XPath expression * @return the first element matching the specified XPath expression */ public static <X> X selectSingleNode(final DomNode domNode, final String xpathExpr) { WebClientUtil.waitForJSExec(domNode.getPage().getWebClient()); return domNode.<X>getFirstByXPath(xpathExpr); } }