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

烈酒焚心 提交于 2019-11-30 05:29:59

问题


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?


回答1:


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();




回答2:


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



来源:https://stackoverflow.com/questions/5168473/how-can-i-use-selenium-rc-to-verify-our-server-side-redirects-301-302

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!