use of com.gargoylesoftware.htmlunit.html.HtmlParagraph in project faces by jakartaee.
the class Spec1IT method testSimpleValidFieldsValidBean.
/**
* @see com.sun.faces.ext.component.UIValidateWholeBean
* @see https://github.com/jakartaee/faces/issues/1
*/
@Test
public void testSimpleValidFieldsValidBean() throws Exception {
HtmlPage page = webClient.getPage(webUrl);
HtmlTextInput password1 = page.getHtmlElementById("password1");
password1.setValueAttribute("foofoofoo");
HtmlTextInput password2 = page.getHtmlElementById("password2");
password2.setValueAttribute("foofoofoo");
HtmlSubmitInput button = page.getHtmlElementById("submit");
page = button.click();
String pageText = page.asXml();
assertTrue(!pageText.contains("[foofoofoo]"));
assertTrue(!pageText.contains("[barbarbar]"));
assertTrue(!pageText.contains("Password fields must match"));
HtmlParagraph password1Value = page.getHtmlElementById("password1Value");
assertTrue(password1Value.asNormalizedText().contains("foofoofoo"));
HtmlParagraph password2Value = page.getHtmlElementById("password2Value");
assertTrue(password2Value.asNormalizedText().contains("foofoofoo"));
}
use of com.gargoylesoftware.htmlunit.html.HtmlParagraph in project maven-doxia-sitetools by apache.
the class EntitiesVerifier method verify.
/**
* {@inheritDoc}
*/
public void verify(String file) throws Exception {
HtmlPage page = htmlPage(file);
assertNotNull(page);
HtmlMeta author = (HtmlMeta) page.getElementsByName("author").get(0);
assertNotNull(author);
assertTrue(author.toString().indexOf("Ligature \u00C6") > 0);
assertEquals("Ligature \u00C6", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(1);
assertNotNull(author);
assertTrue(author.toString().indexOf("Ampersand &") > 0);
assertEquals("Ampersand &", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(2);
assertNotNull(author);
assertTrue(author.toString().indexOf("Less than <") > 0);
assertEquals("Less than <", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(3);
assertNotNull(author);
assertTrue(author.toString().indexOf("Greater than >") > 0);
assertEquals("Greater than >", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(4);
assertNotNull(author);
assertEquals("Apostrophe '", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(5);
assertNotNull(author);
assertTrue(author.toString().indexOf("Quote "") > 0);
assertEquals("Quote \"", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(6);
assertNotNull(author);
assertTrue(author.toString().indexOf("test@email.com") > 0);
assertEquals("test@email.com", author.getContentAttribute());
author = (HtmlMeta) page.getElementsByName("author").get(7);
assertNotNull(author);
assertTrue(author.toString().indexOf("test\u00A9email.com") > 0);
assertEquals("test\u00A9email.com", author.getContentAttribute());
HtmlElement element = page.getHtmlElementById("contentBox");
assertNotNull(element);
HtmlDivision division = (HtmlDivision) element;
assertNotNull(division);
Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
HtmlSection section = (HtmlSection) elementIterator.next();
HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
assertNotNull(h2);
assertEquals(h2.asText().trim(), "section name with entities: '&' '\u0391' ' ' '\uD835\uDFED'");
HtmlAnchor a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("section_name_with_entities:_.27.26.27_.27.CE.91.27_.27.C2.A0.27_.27.3F.3F.27", a.getAttribute("name"));
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading4 h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("Entities", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("Entities", a.getAttribute("name"));
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading3 h3 = (HtmlHeading3) elementIterator.next();
assertNotNull(h3);
assertEquals("Generic Entities: '&' '<' '>' '\"' '''", h3.asText().trim());
a = (HtmlAnchor) elementIterator.next();
HtmlParagraph p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("'&' '<' '>' '\"' '''", p.asText().trim());
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h3 = (HtmlHeading3) elementIterator.next();
assertNotNull(h3);
assertEquals("Local Entities: '\u0391' '\u0392' '\u0393' '\uD835\uDFED'", h3.asText().trim());
a = (HtmlAnchor) elementIterator.next();
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("'\u0391' '\u0392' '\u0393' '\uD835\uDFED\uD835\uDFED' '\u0159\u0159' '\u0159'", p.asText().trim());
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h3 = (HtmlHeading3) elementIterator.next();
assertNotNull(h3);
assertEquals("DTD Entities: ' ' '\u00A1' '\u00A2'", h3.asText().trim());
a = (HtmlAnchor) elementIterator.next();
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("' ' '\u00A1' '\u00A2'", p.asText().trim());
section = (HtmlSection) elementIterator.next();
assertNotNull(section);
h4 = (HtmlHeading4) elementIterator.next();
assertNotNull(h4);
assertEquals("CDATA", h4.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("CDATA", a.getAttribute("name"));
HtmlDivision div = (HtmlDivision) elementIterator.next();
assertNotNull(div);
HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
assertNotNull(pre);
assertEquals("<project xmlns:ant=\"jelly:ant\">", pre.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("' ' '¡'", p.asText().trim());
assertFalse(elementIterator.hasNext());
}
use of com.gargoylesoftware.htmlunit.html.HtmlParagraph in project maven-doxia-sitetools by apache.
the class FaqVerifier method verify.
/**
* {@inheritDoc}
*/
public void verify(String file) throws Exception {
HtmlPage page = htmlPage(file);
assertNotNull(page);
HtmlElement element = page.getHtmlElementById("contentBox");
assertNotNull(element);
HtmlDivision division = (HtmlDivision) element;
assertNotNull(division);
Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
HtmlSection section = (HtmlSection) elementIterator.next();
HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
assertEquals("Oft Asked Questions", h2.asText().trim());
HtmlAnchor a = (HtmlAnchor) elementIterator.next();
assertEquals(a.getAttribute("name"), "Oft_Asked_Questions");
a = (HtmlAnchor) elementIterator.next();
assertEquals("top", a.getAttribute("name"));
HtmlParagraph p = (HtmlParagraph) elementIterator.next();
element = elementIterator.next();
assertEquals("b", element.getTagName());
assertEquals("Contributing", element.asText().trim());
HtmlOrderedList ol = (HtmlOrderedList) elementIterator.next();
assertEquals("One stupid question & a silly answer?", ol.getFirstElementChild().asText().trim());
HtmlListItem li = (HtmlListItem) elementIterator.next();
assertEquals("One stupid question & a silly answer?", li.getFirstElementChild().asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("#stupid-question", a.getAttribute("href"));
element = elementIterator.next();
assertEquals("b", element.getTagName());
assertEquals("stupid", element.asText().trim());
p = (HtmlParagraph) elementIterator.next();
element = elementIterator.next();
assertEquals("b", element.getTagName());
assertEquals("Using Maven", element.asText().trim());
ol = (HtmlOrderedList) elementIterator.next();
assertEquals("How do I disable a report on my site?", ol.getFirstElementChild().asText().trim());
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("How do I disable a report on my site?", li.getFirstElementChild().asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("#disable-reports", a.getAttribute("href"));
section = (HtmlSection) elementIterator.next();
h2 = (HtmlHeading2) elementIterator.next();
assertEquals("Contributing", h2.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("Contributing", a.getAttribute("name"));
HtmlDefinitionList dl = (HtmlDefinitionList) elementIterator.next();
HtmlDefinitionTerm dt = (HtmlDefinitionTerm) elementIterator.next();
assertEquals("One stupid question & a silly answer?", dt.getFirstChild().asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("stupid-question", a.getAttribute("name"));
element = elementIterator.next();
assertEquals("b", element.getTagName());
assertEquals("stupid", element.asText().trim());
HtmlDefinitionDescription dd = (HtmlDefinitionDescription) elementIterator.next();
p = (HtmlParagraph) elementIterator.next();
a = (HtmlAnchor) elementIterator.next();
assertEquals("#Using_Maven", a.getAttribute("href"));
assertEquals("local link", a.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("./cdc.html", a.getAttribute("href"));
assertEquals("source document", a.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("http://maven.apache.org/?l=a&m=b", a.getAttribute("href"));
assertEquals("external link", a.asText().trim());
element = elementIterator.next();
assertEquals("i", element.getTagName());
assertEquals("italic", element.asText().trim());
element = elementIterator.next();
assertEquals("b", element.getTagName());
assertEquals("non-US-ASCII characters: àéèç", element.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertEquals("right", p.getAttribute("align"));
a = (HtmlAnchor) elementIterator.next();
assertEquals("#top", a.getAttribute("href"));
assertEquals("[top]", a.asText().trim());
section = (HtmlSection) elementIterator.next();
h2 = (HtmlHeading2) elementIterator.next();
assertEquals("Using Maven", h2.asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("Using_Maven", a.getAttribute("name"));
dl = (HtmlDefinitionList) elementIterator.next();
dt = (HtmlDefinitionTerm) elementIterator.next();
assertEquals("How do I disable a report on my site?", dt.getFirstChild().asText().trim());
a = (HtmlAnchor) elementIterator.next();
assertEquals("disable-reports", a.getAttribute("name"));
dd = (HtmlDefinitionDescription) elementIterator.next();
p = (HtmlParagraph) elementIterator.next();
element = elementIterator.next();
assertEquals("code", element.getTagName());
assertEquals("<source></source>", element.asText().trim());
HtmlDivision div = (HtmlDivision) elementIterator.next();
assertEquals("source", div.getAttribute("class"));
HtmlPreformattedText pre = (HtmlPreformattedText) elementIterator.next();
assertEquals("<source>1.5</source>", pre.asText().trim());
p = (HtmlParagraph) elementIterator.next();
assertEquals("right", p.getAttribute("align"));
a = (HtmlAnchor) elementIterator.next();
assertEquals("#top", a.getAttribute("href"));
assertEquals("[top]", a.asText().trim());
assertFalse(elementIterator.hasNext());
}
use of com.gargoylesoftware.htmlunit.html.HtmlParagraph in project maven-doxia-sitetools by apache.
the class MultipleBlockVerifier method verify.
/**
* {@inheritDoc}
*/
public void verify(String file) throws Exception {
HtmlPage page = htmlPage(file);
assertNotNull(page);
HtmlElement element = page.getHtmlElementById("contentBox");
assertNotNull(element);
HtmlDivision division = (HtmlDivision) element;
assertNotNull(division);
Iterator<HtmlElement> elementIterator = division.getHtmlElementDescendants().iterator();
// ----------------------------------------------------------------------
// Verify link
// ----------------------------------------------------------------------
HtmlSection section = (HtmlSection) elementIterator.next();
assertNotNull(section);
HtmlHeading2 h2 = (HtmlHeading2) elementIterator.next();
assertNotNull(h2);
assertEquals("section name", h2.asText().trim());
HtmlAnchor a = (HtmlAnchor) elementIterator.next();
assertNotNull(a);
assertEquals("section_name", a.getAttribute("name"));
// ----------------------------------------------------------------------
// Paragraph
// ----------------------------------------------------------------------
HtmlParagraph p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("text", p.asText().trim());
// ----------------------------------------------------------------------
// Unordered list
// ----------------------------------------------------------------------
HtmlUnorderedList ul = (HtmlUnorderedList) elementIterator.next();
assertNotNull(ul);
HtmlListItem li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("list1", li.getFirstChild().asText().trim());
// ----------------------------------------------------------------------
// Paragraph
// ----------------------------------------------------------------------
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("text2", p.asText().trim());
// ----------------------------------------------------------------------
// Unordered list
// ----------------------------------------------------------------------
ul = (HtmlUnorderedList) elementIterator.next();
assertNotNull(ul);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
assertEquals("list1", li.getFirstChild().asText().trim());
// ----------------------------------------------------------------------
// Paragraph
// ----------------------------------------------------------------------
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("text3", p.asText().trim());
// ----------------------------------------------------------------------
// Unordered list
// ----------------------------------------------------------------------
ul = (HtmlUnorderedList) elementIterator.next();
assertNotNull(ul);
li = (HtmlListItem) elementIterator.next();
assertNotNull(li);
p = (HtmlParagraph) elementIterator.next();
assertNotNull(p);
assertEquals("list1", p.getFirstChild().asText().trim());
assertFalse(elementIterator.hasNext());
}
use of com.gargoylesoftware.htmlunit.html.HtmlParagraph in project faces by jakartaee.
the class Spec1IT method testSimpleInvalidField.
/**
* @see com.sun.faces.ext.component.UIValidateWholeBean
* @see https://github.com/jakartaee/faces/issues/1
*/
@Test
public void testSimpleInvalidField() throws Exception {
HtmlPage page = webClient.getPage(webUrl);
HtmlTextInput password1 = page.getHtmlElementById("password1");
password1.setValueAttribute("foofoofoo");
HtmlTextInput password2 = page.getHtmlElementById("password2");
password2.setValueAttribute("bar");
HtmlSubmitInput button = page.getHtmlElementById("submit");
page = button.click();
String pageText = page.asXml();
assertTrue(!pageText.contains("[foofoofoo]"));
assertTrue(pageText.contains("[bar]"));
assertTrue(!pageText.contains("Password fields must match"));
HtmlParagraph password1Value = page.getHtmlElementById("password1Value");
assertTrue(password1Value.asNormalizedText().isEmpty());
HtmlParagraph password2Value = page.getHtmlElementById("password2Value");
assertTrue(password2Value.asNormalizedText().isEmpty());
}
Aggregations