MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / post

Method post

src/test/java/org/htmlunit/HistoryTest.java:51–81  ·  view source on GitHub ↗

Tests going in history History#back() with POST request. @throws Exception if an error occurs

()

Source from the content-addressed store, hash-verified

49 * @throws Exception if an error occurs
50 */
51 @Test
52 public void post() throws Exception {
53 final Map<String, Class<? extends Servlet>> servlets = new HashMap<>();
54 servlets.put("/post1", Post1Servlet.class);
55 servlets.put("/post2", Post2Servlet.class);
56 servlets.put("/post3", Post3Servlet.class);
57 startWebServer("./", servlets);
58
59 final WebDriver driver = getWebDriver();
60 driver.get(URL_FIRST + "post1");
61
62 driver.findElement(By.id("mySubmit")).click();
63 if (useRealBrowser()) {
64 Thread.sleep(400);
65 }
66 assertEquals(URL_FIRST + "post2", driver.getCurrentUrl());
67 assertTrue(driver.getPageSource().contains("POST"));
68 assertTrue(driver.getPageSource().contains("para1=value1"));
69
70 driver.findElement(By.linkText("Go to GET")).click();
71 if (useRealBrowser()) {
72 Thread.sleep(400);
73 }
74 assertEquals(URL_FIRST + "post3", driver.getCurrentUrl());
75 assertTrue(driver.getPageSource().contains("GET"));
76
77 driver.navigate().back();
78 assertEquals(URL_FIRST + "post2", driver.getCurrentUrl());
79 assertTrue(driver.getPageSource().contains("POST"));
80 assertTrue(driver.getPageSource().contains("para1=value1"));
81 }
82
83 /**
84 * Tests going in history {@link History#back()} with {@code POST} request.

Callers 5

ajax.jsFile · 0.45
ajax.jsFile · 0.45
ajax.jsFile · 0.45
ajax.jsFile · 0.45
JsonService.jsFile · 0.45

Calls 13

useRealBrowserMethod · 0.80
sleepMethod · 0.80
assertTrueMethod · 0.80
navigateMethod · 0.80
containsMethod · 0.65
putMethod · 0.45
startWebServerMethod · 0.45
getWebDriverMethod · 0.45
getMethod · 0.45
clickMethod · 0.45
idMethod · 0.45
assertEqualsMethod · 0.45

Tested by

no test coverage detected