List<DomNode> companies = (List<DomNode>) page.getByXPath("//li[contains(@class, 'featured block']"); for (DomNode node : companies) { // retrieve telephone number DomNode telephone = (DomNode) node.getByXPath( "div[@class='listingWrapper']/div[@class='itemInfo']/span[@class='tel']").get(0);
public <E> List<E> selectNodes(final String xpathExpr) { return getByXPath(xpathExpr); }
public <E> List<E> selectNodes(final String xpathExpr) { return getByXPath(xpathExpr); }
@Override protected List<DomNode> computeElements() { return new ArrayList<>(domNode.getByXPath(expression)); } };
@Override protected List<DomNode> computeElements() { return new ArrayList<>(domNode.getByXPath(expression)); } };
public static List<HtmlTable> getTables(DomNode page) { ArrayList<HtmlTable> list = new ArrayList<>(); list.addAll((Collection<? extends HtmlTable>) page.getByXPath("//table")); return list; }
/** * 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. * * @param xpathExpr the XPath expression * @param <X> the expression type * @return the first element matching the specified XPath expression * @see #getByXPath(String) * @see #getCanonicalXPath() */ @SuppressWarnings("unchecked") public <X> X getFirstByXPath(final String xpathExpr) { final List< ? > results = getByXPath(xpathExpr); if (results.isEmpty()) { return null; } return (X) results.get(0); }
/** * 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. * * @param xpathExpr the XPath expression * @param <X> the expression type * @return the first element matching the specified XPath expression * @see #getByXPath(String) * @see #getCanonicalXPath() */ @SuppressWarnings("unchecked") public <X> X getFirstByXPath(final String xpathExpr) { final List< ? > results = getByXPath(xpathExpr); if (results.isEmpty()) { return null; } return (X) results.get(0); }
/** * 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 * @param resolver the prefix resolver to use for resolving namespace prefixes, or null * @return the first element matching the specified XPath expression * @see #getByXPath(String) * @see #getCanonicalXPath() */ @SuppressWarnings("unchecked") public <X> X getFirstByXPath(final String xpathExpr, final PrefixResolver resolver) { final List<?> results = getByXPath(xpathExpr, resolver); if (results.isEmpty()) { return null; } return (X) results.get(0); }
/** * Asserts that the XPath matches the contents of a DomNode page. This * variant of assertXPath(HtmlPage page, String xpath) allows us to examine * XmlPages. * * @param page * @param xpath */ public void assertXPath(DomNode page, String xpath) { List< ? extends Object> nodes = page.getByXPath(xpath); assertFalse("There should be an object that matches XPath:" + xpath, nodes.isEmpty()); }
/** Asserts that the XPath matches the contents of a DomNode page. This * variant of assertXPath(HtmlPage page, String xpath) allows us to * examine XmlPages. * @param page * @param xpath */ public void assertXPath(DomNode page, String xpath) { List< ? extends Object> nodes = page.getByXPath(xpath); assertFalse("There should be an object that matches XPath:"+xpath, nodes.isEmpty()); }
/** Asserts that the XPath matches the contents of a DomNode page. This * variant of assertXPath(HtmlPage page, String xpath) allows us to * examine XmlPages. * @param page * @param xpath */ public void assertXPath(DomNode page, String xpath) { List<? extends Object> nodes = page.getByXPath(xpath); assertThat("There should be an object that matches XPath:" + xpath, nodes.isEmpty(), is(false)); }
/** Asserts that the XPath matches the contents of a DomNode page. This * variant of assertXPath(HtmlPage page, String xpath) allows us to * examine XmlPages. * @param page * @param xpath */ public void assertXPath(DomNode page, String xpath) { List< ? extends Object> nodes = page.getByXPath(xpath); assertFalse("There should be an object that matches XPath:" + xpath, nodes.isEmpty()); }
/** Asserts that the XPath matches the contents of a DomNode page. This * variant of assertXPath(HtmlPage page, String xpath) allows us to * examine XmlPages. * @param page * @param xpath */ public void assertXPath(DomNode page, String xpath) { List< ? extends Object> nodes = page.getByXPath(xpath); assertFalse("There should be an object that matches XPath:"+xpath, nodes.isEmpty()); }
public void assertXPathResultsContainText(DomNode page, String xpath, String needle) { List<? extends Object> nodes = page.getByXPath(xpath); assertFalse("no nodes matching xpath found", nodes.isEmpty()); boolean found = false; for (Object o : nodes) { if (o instanceof org.w3c.dom.Node) { org.w3c.dom.Node n = (org.w3c.dom.Node) o; String textString = n.getTextContent(); if ((textString != null) && textString.contains(needle)) { found = true; break; } } } assertTrue("needle found in haystack", found); }
public void assertXPathResultsContainText(DomNode page, String xpath, String needle) { List<? extends Object> nodes = page.getByXPath(xpath); assertThat("no nodes matching xpath found", nodes.isEmpty(), is(false)); boolean found = false; for (Object o : nodes) { if (o instanceof org.w3c.dom.Node) { org.w3c.dom.Node n = (org.w3c.dom.Node) o; String textString = n.getTextContent(); if ((textString != null) && textString.contains(needle)) { found = true; break; } } } assertThat("needle found in haystack", found, is(true)); }
public void assertXPathResultsContainText(DomNode page, String xpath, String needle) { List<? extends Object> nodes = page.getByXPath(xpath); assertFalse("no nodes matching xpath found", nodes.isEmpty()); boolean found = false; for (Object o : nodes) { if (o instanceof org.w3c.dom.Node) { org.w3c.dom.Node n = (org.w3c.dom.Node) o; String textString = n.getTextContent(); if ((textString != null) && textString.contains(needle)) { found = true; break; } } } assertTrue("needle found in haystack", found); }
public void assertXPathResultsContainText(DomNode page, String xpath, String needle) { List<? extends Object> nodes = page.getByXPath(xpath); assertFalse("no nodes matching xpath found", nodes.isEmpty()); boolean found = false; for (Object o : nodes) { if (o instanceof org.w3c.dom.Node) { org.w3c.dom.Node n = (org.w3c.dom.Node) o; String textString = n.getTextContent(); if ((textString != null) && textString.contains(needle)) { found = true; break; } } } assertTrue("needle found in haystack", found); }
public void assertXPathResultsContainText(DomNode page, String xpath, String needle) { List<? extends Object> nodes = page.getByXPath(xpath); assertFalse("no nodes matching xpath found", nodes.isEmpty()); boolean found = false; for (Object o : nodes) { if (o instanceof org.w3c.dom.Node) { org.w3c.dom.Node n = (org.w3c.dom.Node) o; String textString = n.getTextContent(); if ((textString != null) && textString.contains(needle)) { found = true; break; } } } assertTrue("needle found in haystack", found); }
private void clickSpinnerButton(String componentID, String imageName) throws IOException { DomNode table = (DomNode)jsfClient.getElement(componentID + "Buttons"); List inputs = table.getByXPath("tbody/tr/td/input"); for (Iterator i = inputs.iterator(); i.hasNext();) { HtmlInput input = (HtmlInput)i.next(); if (input.asXml().contains(imageName)) { input.click(); return; } } throw new RuntimeException("Can't find image for " + imageName); }