Re: Unable to view the Web Application I am testingusing httpunit
malathi gopalan <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Thanks Band for the response. I don't want to write the response to a page, but I would like to view the GUI for the web application that I am testing. Thanks Malathi --- "Band, Tyler" <[email protected]> wrote: > This is what I use to 'write' a page out - since > this is a load test - I > needed to uniquely identify the page so I included a > random system time > and the logon name. This only writes the page out if > there is an error. > Enjoy > > > > private void writeErrorPage(WebResponse response) > throws Exception { > if (response != null) { > if (pageTitle == null) > pageTitle = response.getTitle(); > long time = System.currentTimeMillis() / 1000; > String mFilePath = mState.getMThreadID() + "_[" > + mState.getUserName() + "]_" + pageTitle + > "_" > + String.valueOf(time) + ".html"; > String content = response.getText(); > FileOutputStream out = new > FileOutputStream(mFilePath); > PrintWriter writer = new PrintWriter(out); > writer.print(content); > writer.close(); > pageTitle = null; > } > } > > Tyler Band > Marriott Vacation Club > Orlando, FL > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] > On Behalf Of > malathi gopalan > Sent: Tuesday, October 30, 2007 3:21 PM > To: [email protected] > Subject: [Httpunit-develop] Unable to view the Web > Application I am > testingusing httpunit > > Hi, > > I am using HttpUnit1.6 and jdk 1.5_02. > I am trying to test a Web Application using httpunit > and I am able to have the web conversation with the > application and getting the appropiate values for my > > tests, Everything is happening in the background, I > would like to view what is happening in the > application for example the login page, view the > form > submit, clicking on a link etc. > > I appreciate if anyone can help me. > > Thanks > > Below is the code that I used for HttpUnit. > > public class sampleHttpUnitTest extends TestCase > { > public void testConnection() throws Exception > { > > String url = "www.bmc.com" > WebConversation wc = new WebConversation(); > > WebRequest request = new > GetMethodWebRequest(url); > > WebResponse response = > wc.getResponse(request); > > assertEquals("The Web page returned the > wrong > respons code ",200, > response.getResponseCode()); > > System.out.println("Title : " + > response.getTitle()); > > WebLink [] webLinkList = > response.getLinks(); > > String[] elementNameList = > response.getElementNames(); > > for(WebLink weblink : webLinkList ) > { > System.out.println(" WebLink Text is " + > weblink.getText()); > > } > > for(String elementName : elementNameList ) > { > System.out.println(" ElementName is " + > elementName); > } > > WebForm [] webFormList = > response.getForms(); > > for(WebForm webForm : webFormList) > { > System.out.println("name : "+ > webForm.getName() + " Text : " + webForm.getText() + > "Id : " + webForm.getID()); > > SubmitButton[] submitButtonList = > webForm.getSubmitButtons(); > > for(SubmitButton button : > submitButtonList) > { > System.out.println(" Submit Button > name : " + button.getName()); > //webForm.submit(button); > > } > > webForm.setParameter("j_username", > "admin"); > webForm.setParameter("j_password", > "quality1"); > > response = webForm.submit(); > > System.out.println("Title in response > page > is : " + response.getTitle()); > > WebLink [] responseWebLinkList = > response.getLinks(); > > String[] responseElementNameList = > response.getElementNames(); > > for(WebLink weblink : > responseWebLinkList > ) > { > System.out.println(" Response > WebLink > Text is " + weblink.getText()); > > } > > for(int i=0; > i<responseWebLinkList.length; > i++) > { > > if(responseWebLinkList[i].getText().equals("continue")) > { > WebResponse responseEvent = > responseWebLinkList[i].click(); > > for(WebLink weblink : > responseEvent.getLinks()) > { > System.out.println("WebLinks > in Events page is " + weblink.getText()); > } > > } > > } > > } > > } > } > > > > > > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > ------------------------------------------------------------------------ > - > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? > Stop. > Now Search log events and configuration files using > AJAX === message truncated === __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/