Skip to content

Commit 12faa31

Browse files
Create HtmlUnitAndJUnitTest.java
1 parent b882a23 commit 12faa31

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.htmlunit;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
import com.gargoylesoftware.htmlunit.WebClient;
7+
import com.gargoylesoftware.htmlunit.html.HtmlPage;
8+
9+
public class HtmlUnitAndJUnitTest {
10+
11+
@Test
12+
public void givenAClient_whenEnteringBaeldung_thenPageTitleIsCorrect() throws Exception {
13+
try (final WebClient webClient = new WebClient()) {
14+
15+
webClient.getOptions().setThrowExceptionOnScriptError(false);
16+
17+
final HtmlPage page = webClient.getPage("http://www.baeldung.com/");
18+
Assert.assertEquals("Baeldung | Java, Spring and Web Development tutorials", page.getTitleText());
19+
}
20+
}
21+
22+
}

0 commit comments

Comments
 (0)