Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Selenium RC to verify our Server-Side-Redirects (301, 302)?

We have a bunch of redirects in our Apache configuration. I would like to automate the testing of redirects with Selenium, which led me to some problems:

  • Call an URL, but assert on the redirected page
  • Check the URL of the browser after redirected
  • Check Response Header, to determine the type of redirection (301, 302)

Maybe Selenium is not the best solution for this. Any other suggestions?

like image 845
timomeinen Avatar asked Mar 02 '11 14:03

timomeinen


2 Answers

Selenium-RC has a traffic capture mode, defined as selenium.start("captureNetworkTraffic=true"); that will enable you to capture HTTP responses, including redirects and error codes.

Here is an excellent resource on how to capture and process/format this information once retrieved. It uses Python, though, but should give you a start.

For checking the URL of browser, you could use selenium.getLocation();

like image 75
rs79 Avatar answered Oct 20 '22 01:10

rs79


in python's implementation,

driver = webdriver.Firefox()
print driver.current_url

http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html#module-selenium.webdriver.remote.webdriver

like image 32
joetsuihk Avatar answered Oct 19 '22 23:10

joetsuihk