Create HtmlUnitAndJUnitTest.java

This commit is contained in:
Juan García Heredero 2016-08-01 10:44:45 +02:00 committed by GitHub
parent b882a23ab6
commit 12faa318ae
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package com.baeldung.htmlunit;
import org.junit.Assert;
import org.junit.Test;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class HtmlUnitAndJUnitTest {
@Test
public void givenAClient_whenEnteringBaeldung_thenPageTitleIsCorrect() throws Exception {
try (final WebClient webClient = new WebClient()) {
webClient.getOptions().setThrowExceptionOnScriptError(false);
final HtmlPage page = webClient.getPage("http://www.baeldung.com/");
Assert.assertEquals("Baeldung | Java, Spring and Web Development tutorials", page.getTitleText());
}
}
}