Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate back/forward/refresh button in unit test with Wicket

I'd like to unit test (jUnit 4) the behavior of my pages when the browser's back button (or forward or refresh) is clicked.

Can I somehow simulate the browser's back/forward/refresh buttons in a unit test? Is there a utility class that provides such functionality?

2nd Edit:

I understand that the Wicket test facilities don't simulate a browser with a full history. From my understanding I would need the following two things to simulate a browser's behavior from a unit test:

(1) Wicket has to tell me what exact request (e.g. URL) is made when I call WicketTester.startPage() or WicketTester.clickLink().

(2) Wicket has to process the same request again, e.g. by accepting the URL previously recorded by (1).

I want to do this in a way that is compatible with WicketTester, FormTester and so on as I'm using the component finders, asserts, and more nice functionality in these classes. That means that I have to issue the requests from Wicket facilities and not from external clients like HttpUnit / HtmlUnit / Selenium.

like image 936
Wolfgang Avatar asked Dec 21 '25 00:12

Wolfgang


1 Answers

This is pretty certainly not supported by WicketTester, which explicitly uses a dummy WebApplication not supporting the back button to save resources.

I suspect it would be painful to simulate in Wicket...

Your best bet might be to use a browser-based testing tool like Selenium RC. I haven't tried it myself, but it does have a goBack() method that will simulate a click on the browser back button.

like image 140
Don Roby Avatar answered Dec 22 '25 18:12

Don Roby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!