Re: Clicking on link does not take me to that page.

"Xiuping Hu" <[email protected]>
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
You need to get the new window, try this:

public WebResponse navigateToLinkInNewWindow(final WebConversation wc, final 
String linkText) {
		try {
			WebLink link = 
getResponse().getFirstMatchingLink(WebLink.MATCH_CONTAINED_TEXT, linkText);
			if (link == null) {
				String msg = "Link with text '" + linkText + "' not found on page " + 
getPageName();
				throw new AcceptanceTestException(msg);
			}
			String strOnClick = link.getAttribute("onclick");
			link.getScriptableDelegate().doEvent(strOnClick);
			WebResponse linkResponse = link.click();
			ensureNotErrorPage(linkResponse);
			WebWindow[] windows = wc.getOpenWindows();
			return windows[windows.length - 1].getCurrentPage();
		} catch (SAXException e) {
			throw new RuntimeException(e);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

Good luck,

Xiuping Hu

>From: "Sunil" <[email protected]>
>Reply-To: [email protected],Discussion of use and development of HttpUnit 
><[email protected]>
>To: [email protected]
>Subject: [Httpunit-develop] Clicking on link does not take me to that page.
>Date: Thu,  9 Nov 2006 18:44:49 -0500 (EST)
>
>  Hello All, This is my first message to the list. I am using HTTPUnit to 
>test a web application. I am trying to click on a link (called Logout) that 
>has the 
>URL:http://staqj08.us.oracle.com:7778/sso/logout?p_done_url=http://staqj08.us.oracle.com:7778/sso/index.jspHowever 
>when I do a get response.getLinkWith("Logout") I only get 
>/sso/logout?p_done_url=http://staqj08.us.oracle.com:7778/sso/index.jspAfter 
>getting the link I do a Logout.click();This step does not seem to work and 
>I am on the same page and have not moved on to that page pointed to by that 
>link. I have also tried constructing the literal URL and passing it to 
>GetMethodWebRequest as follows:Where LogoutURL = 
>http://staqj08.us.oracle.com:7778/sso/logout?p_done_url=http://staqj08.us.oracle.com:7778/sso/index.jspreq 
>= new GetMethodWebRequest (LogoutURL);WebResponse LoggedInPage = 
>ctx.getResponse(req);Even after this I do a ctx.getCurrentPage(); but I 
>still find myself on the same page.I am not sure how I can solve this
>
>problem. Any help will be appreciated.  Thanks,Sunil
>
>_______________________________________________
>No banners. No pop-ups. No kidding.
>Make My Way  your home on the Web - http://www.myway.com


>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job 
>easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


>_______________________________________________
>Httpunit-develop mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/httpunit-develop



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.