MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / click

Method click

src/test/java/org/htmlunit/html/HtmlOptionTest.java:133–151  ·  view source on GitHub ↗

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

131 * @throws Exception if the test fails
132 */
133 @Test
134 public void click() throws Exception {
135 final String htmlContent = DOCTYPE_HTML
136 + "<html><body>\n"
137 + " <form id='form1'>\n"
138 + " <select name='select1' id='select1'>\n"
139 + " <option id='option1'>Option1</option>\n"
140 + " <option id='option2' selected>Number Two</option>\n"
141 + " </select>\n"
142 + "</form></body></html>";
143 final HtmlPage page = loadPage(htmlContent);
144
145 final HtmlOption option1 = page.getHtmlElementById("option1");
146 assertFalse(option1.isSelected());
147 option1.click();
148 assertTrue(option1.isSelected());
149 option1.click();
150 assertTrue(option1.isSelected());
151 }
152
153 /**
154 * @throws Exception if the test fails

Callers

nothing calls this directly

Calls 5

getHtmlElementByIdMethod · 0.95
isSelectedMethod · 0.95
assertFalseMethod · 0.80
assertTrueMethod · 0.80
loadPageMethod · 0.45

Tested by

no test coverage detected