01: package com.canoo.webtest.steps.request;
02:
03: import com.canoo.webtest.engine.StepExecutionException;
04: import com.canoo.webtest.self.TestBlock;
05: import com.canoo.webtest.self.ThrowAssert;
06: import com.canoo.webtest.steps.BaseStepTestCase;
07: import com.canoo.webtest.steps.Step;
08: import com.gargoylesoftware.htmlunit.html.HtmlPage;
09:
10: /**
11: * Tests for {@link FollowFrame}.
12: * @author <a href="torben@tretau.net">Torben Tretau</a>
13: * @author Marc Guillemot
14: */
15: public class FollowFrameTest extends BaseStepTestCase {
16:
17: protected Step createStep() {
18: return new FollowFrame();
19: }
20:
21: public void testParameters() {
22: final FollowFrame step = (FollowFrame) getStep();
23:
24: final String msg = ThrowAssert.assertThrows(
25: StepExecutionException.class, new TestBlock() {
26: public void call() throws Exception {
27: step.verifyParameters();
28: }
29: });
30:
31: assertEquals("\"name\" or \"htmlId\" must be set!", msg);
32: }
33:
34: public void testWithNoWebConversation() throws Exception {
35: final FollowFrame step = (FollowFrame) getStep();
36: step.setName("name");
37: assertStepRejectsNullResponse(step);
38: }
39:
40: public void testGetFrameByName() throws Exception {
41: final String htmlContent = "<html><body><frameset rows='*'><frame name='dummy' src='about:blank'></frameset></body></html>";
42: final HtmlPage page = getDummyPage(htmlContent);
43: assertEquals("about:blank", FollowFrame.getFrame(page, "dummy",
44: null).getEnclosedPage().getWebResponse().getUrl()
45: .toExternalForm());
46: }
47:
48: public void testGetFrameById() throws Exception {
49: final String htmlContent = "<html><body><frameset rows='*'><frame id='dummy' src='about:blank'></frameset></body></html>";
50: final HtmlPage page = getDummyPage(htmlContent);
51: assertEquals("about:blank", FollowFrame.getFrame(page, null,
52: "dummy").getEnclosedPage().getWebResponse().getUrl()
53: .toExternalForm());
54: }
55:
56: public void testNestedText() throws Exception {
57: testNestedTextEquivalent(getStep(), "name");
58: }
59: }
|