question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

status_code is only ever 200 - OK.

See original GitHub issue

See attached testcase.

A status_code of 200 seems to be hard-coded since this commit?

https://github.com/cobrateam/splinter/commit/d151c565c1068c6f0ac3f09ff010353b9b1a9de2

import splinter

with splinter.Browser('firefox') as browser:
    # should be 200
    browser.visit('http://google.com')
    print(browser.status_code.code)
    print(browser.status_code.is_success())

    browser.visit('http://google.com/is_this_a_bug')
    print(browser.status_code.code)
    print(browser.status_code.is_success())

    browser.visit('http://github.com/is_this_a_bug/is_this_a_bug_project')
    print(browser.status_code.code)
    print(browser.status_code.is_success())

    browser.visit('http://this_domain_doesnt_even_exist.coma')
    print(browser.status_code.code)
    print(browser.status_code.is_success())

Gives this output:

$ python ./testcase.py 
200
True
200
True
200
True
200
True

This should be returning 404 for all but the 1st example.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ncoghlancommented, Jul 18, 2017

Someone mentioned this bug to me and I was puzzled as to why I hadn’t noticed it myself, and then realised it was because of the way I had structured my test cases: all my status code tests just use plain requests calls, without invoking splinter at all. I then only use splinter for interaction tests in the 200 OK case.

So +1 from me for having status_code raise NotImplementedError("Selenium WebDriver does not report HTTP status codes") (or some other appropriate message) in cases where the driver can’t set it reliably.

1reaction
samuelcolvincommented, Jul 9, 2017

Multiple requests is difficult, POST requests are likely to not be idempotent, eg. the status code of a POST /create/user/jamesbond/ request the second time is very likely to be different to the first request. Even multiple GET requests could have effects so duplicating them probably does more harm than good.

Leave duplicated requests up to the application developer.

If there really isn’t a reliable way of getting the status code from the main request, I think NotImplementedError is the only sensible solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

200 OK - HTTP - MDN Web Docs
The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default.
Read more >
Returning http 200 OK with error within response body
HTTP 200 means transmission is OK on the HTTP level (i.e request ... But all errors which are covered by HTTP error codes...
Read more >
HTTP Status 200 (OK) - REST
The HTTP Status 200 (OK) status code indicates that the request has been processed successfully on the server. The response payload depends ...
Read more >
Empty list, HTTP status code 200 vs 204 vs 404 - API Handyman
While 200 OK being a valid and the most common answer, returning a 204 No Content could make sense as there is absolutely...
Read more >
200 OK - HTTP Status Code Glossary - WebFX
HTTP Status Code 200: The request has succeeded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found