1 38 package com.gargoylesoftware.htmlunit.html; 39 40 import java.util.ArrayList; 41 import java.util.List; 42 43 import com.gargoylesoftware.htmlunit.KeyValuePair; 44 import com.gargoylesoftware.htmlunit.MockWebConnection; 45 import com.gargoylesoftware.htmlunit.Page; 46 import com.gargoylesoftware.htmlunit.SubmitMethod; 47 import com.gargoylesoftware.htmlunit.WebTestCase; 48 49 55 public class HtmlIsIndexTest extends WebTestCase { 56 61 public HtmlIsIndexTest( final String name ) { 62 super( name ); 63 } 64 65 66 69 public void testFormSubmission() 70 throws Exception { 71 final String htmlContent 72 = "<html><head><title>foo</title></head><body>" 73 + "<form id='form1'>" 74 + "<isindex prompt='enterSomeText'></isindex>" 75 + "</form></body></html>"; 76 final HtmlPage page = loadPage(htmlContent); 77 final MockWebConnection webConnection = getMockConnection(page); 78 79 final HtmlForm form = ( HtmlForm )page.getHtmlElementById( "form1" ); 80 81 final HtmlIsIndex isInput = 82 ( HtmlIsIndex )form.getHtmlElementsByAttribute( 83 "isindex", "prompt", "enterSomeText" ).get( 0 ); 84 isInput.setValue( "Flintstone" ); 85 final Page secondPage = form.submit(); 86 87 final List expectedParameters = new ArrayList(); 88 expectedParameters.add( new KeyValuePair( "enterSomeText", "Flintstone" ) ); 89 90 assertEquals("url", URL_GARGOYLE, secondPage.getWebResponse().getUrl()); 91 assertEquals( "method", SubmitMethod.GET, webConnection.getLastMethod() ); 92 assertEquals( "parameters", expectedParameters, webConnection.getLastParameters() ); 93 } 94 } 95 96 | Popular Tags |