From: Brehm, R. P <rob...@of...> - 2004-09-27 17:13:20
|
Brad C, Here is the failing JUnit test. By the way I am running version 1.2.3. Best Regards, Bob Brehm Software Engineer Xerox Corp. /* * Created on Sep 17, 2004 * */ package junit; import junit.framework.TestCase; import com.gargoylesoftware.htmlunit.*; import com.gargoylesoftware.htmlunit.html.*; import java.net.URL; import java.util.*; /** * @author rbrehm * */ public class LoginJSPHTMLTestJavaScript extends TestCase { public void testLoginPageJavaScript() throws Exception { String LoginFormURL = "http://localhost:8080/Logistics_JSP/"; WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); webClient.setJavaScriptEnabled(true); webClient.setThrowExceptionOnFailingStatusCode(true); webClient.setRedirectEnabled(true); URL url = new URL(LoginFormURL); HtmlPage page = (HtmlPage)webClient.getPage(url); ArrayList arr = (ArrayList) page.getAllForms(); HtmlForm form = (HtmlForm) arr.get(0); assertEquals("loginForm",form.getNameAttribute()); // assertEquals( "Login Page", page.getTitleText()); HtmlButtonInput buttonInput= (HtmlButtonInput) form.getInputByName("loginSubmit"); assertNotNull(buttonInput); form.getInputByName("userName").setValueAttribute("rbrehm"); form.getInputByName("userPassword").setValueAttribute("<password>"); HtmlPage page2 = (HtmlPage) buttonInput.click(); form = page2.getFormByName("headerForm"); assertEquals("headerForm",form.getNameAttribute()); buttonInput= (HtmlButtonInput) form.getInputByName("Logout"); HtmlPage page3 = (HtmlPage) buttonInput.click(); ArrayList arr3 = (ArrayList) page3.getAllForms(); form = (HtmlForm) arr3.get(0); assertEquals("loginForm",form.getNameAttribute()); }//method }//class |