Testing Forward, redirect and download

 This page is about Testing Automation of Forward, redirect and download. This example checks the forward and redirect is done correctly, and  download is done correctly.

In order to understand what test, please take a look at Forward, redirect and download before reading this page.

About test cases

 This testing automation example tests below.

  • Checking to forward collectly
  • Checking to redirect collectly
  • Checking download file collectly

The evidense screen shot is stored at location below.

/[Project]/screenshots/forward

taken screenshots 

Those screenshots a taken by Selenium program using taking screenshot technique.

Location of the source code

 The source code to test this is in "org.alinous.test.html5.basic" package. The test is in the "ForwardDownloadTest" class.

Test case class of JUnit

Initialize WebDriver of the Selenium

 At the first of the JUnit Test class, we initialize and connect the WebDriver, and make the download folder empty.

Forward Testing

 This test case is "test01". In this test case, access the first web page, check the first radio button, and submit the form.

forward test first page

 If the testing scceeded, the url of the web browser doesn't change, but the top of this site appears.

test case success

Source code

The source code of this testing is below.

In this code, goto the first page by calling WebDriver#get(). And Specify the radiob button in the form by xpath below, and get WebElement of the checkbox. The index of array starts with 1, so it writes like "[1]",

Check the checkbox and submit the form. After submit it, check the browser's url by calling WebDriver#getCurrentUrl() and check the returned value.

Redirect Testing

 In this test case, check the second radio button. Submit the form and check the top page appears in the browser, and the borwser's url changes.

redirect test

In the case of forwarding, the url is not changed, but on case of redirection, it changes.

Source code

The source code of this test case is below.

In this code, get the second radio button by xpath below.

And do the same thing with Forward Testing. After that check the url of the web browser. This time, confirm the url has changed into the one of the top page.

Download Testing

In this test case, check the third radio button, submit the form, and check download is done correctly.

download test

Source code

The source code of this test case is below.

In this test case, check the third radio button by xpath below.

After submit the form, download starts, so download it and check the downloaded file. In order to download a file and get it, we use technique, which is mentioned at "Download a file".


Go to Top