问题
How do I ask Selenium IDE to test HTTP Status codes after loading a page? I know this is possible (but awkward) in regular Selenium, how about in Selenium-IDE? Is there a plugin or other way to get something like:
open http://www.example.com/changepassword/obama
assertHTTPStatus 5XX
Thus asserting either success (or this this case failure) or a particular open? Without checking the status code, I have to check page text, which is fragile as someone might redesign the look or feel of the error page.
There are a number of existing Stack questions that touch on this topic without addressing it head on:
- Selenium IDE - always fail on any 500 error
- Checking HTTP Status Code in Selenium
回答1:
You can't. The Selenium developers made a conscious decision not to include this data at the Webdriver level. See webdriver Bug #141 and the blog post Rantings of a Selenium Contributor which lays it out clearly:
Just as proponents of wanting to see HTTP status codes in the WebDriver API are convinced that the arguments against including it don't hold water, the members of the project team are equally convinced that adding it is a bad idea.
If you really want to do it, you'll have to use tricks such as in this answer, or pick a different tool.
来源:https://stackoverflow.com/questions/18391511/how-do-i-ask-selenium-ide-to-check-a-http-status-code-e-g-2xx-404-500