Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser.status_code not available #2

Closed
alvinchow86 opened this issue May 3, 2014 · 13 comments
Closed

browser.status_code not available #2

alvinchow86 opened this issue May 3, 2014 · 13 comments
Assignees

Comments

@alvinchow86
Copy link

I tried to access "status_code" from the browser fixture but it appears to be missing?

print browser.status_code   # get AttributeError

returns

E       AttributeError: 'WebDriver' object has no attribute 'status_code'

venv/lib/python2.7/site-packages/pytest_splinter/plugin.py:29: AttributeError

http://splinter.cobrateam.info/docs/http-status-code-and-exception.html

@bubenkoff
Copy link
Member

normally, when you interact with the browser as a user (which is the case
for browser tests), you don't need status code
status_code is implemented via additional request, which we didn't wan't,
so splinter.request_handler was removed from pytest-splinter wrapper
i'll add this to the documentation
thanks for your report!

On 3 May 2014 21:08, alvinchow86 notifications@github.com wrote:

I tried to access "status_code" from the browser fixture but it appears to
be missing?

print browser.status_code # get AttributeError

returns

E AttributeError: 'WebDriver' object has no attribute 'status_code'

venv/lib/python2.7/site-packages/pytest_splinter/plugin.py:29: AttributeError

http://splinter.cobrateam.info/docs/http-status-code-and-exception.html


Reply to this email directly or view it on GitHubhttps://github.com//issues/2
.

Anatoly Bubenkov

@peterlauri
Copy link
Contributor

Is it really true that browser tests don't need the status code? An example might be a test where a user fills out a form and that a redirect back to the same form should be made. I have to check that it really was an 302, and not an normal 200 from the previous post. Sure, I could make that test with a unit view test, but the project I'm in right now we decided to only make browser tests.

@bubenkoff
Copy link
Member

just, imagine you're the browser user
how you see that you were redirected?
by a changed url in the address bar, right?
so what stops you to check that?
browser.url

@peterlauri
Copy link
Contributor

in my case the redirect goes back to same page :) post(url), redirect(url)

@bubenkoff
Copy link
Member

then you can put some timestamp in the html and compare it

On 23 October 2014 16:54, peterlauri notifications@github.com wrote:

in my case the redirect goes back to same page :) post(url), redirect(url)


Reply to this email directly or view it on GitHub
#2 (comment)
.

Anatoly Bubenkov

@peterlauri
Copy link
Contributor

but why remove splinter functionality at all? if the status_code is not implemented correctly in splinter, as you stated, it should be fixed there I think...

@bubenkoff
Copy link
Member

it's not implemented incorrectly - it's just by design NOT possible to get
the status code via selenium
but, because splinter also supports non-selenium 'browsers' where it's
possible to get the status code natively, they made a compensation for
selenium
but this compensation requires an additional request which slows down the
whole test process
if you feel it absolutely required, let's have a fixture which will control
this (enabling the status code)?

On 23 October 2014 18:29, peterlauri notifications@github.com wrote:

but why remove splinter functionality at all? if the status_code is not
implemented correctly in splinter, as you stated, it should be fixed there
I think...


Reply to this email directly or view it on GitHub
#2 (comment)
.

Anatoly Bubenkov

@blueyed
Copy link
Contributor

blueyed commented Jan 18, 2015

@bubenkoff

but this compensation requires an additional request which slows down the whole test process

Would it be possible to do this extra request lazily, when/if status_code gets accessed?

if you feel it absolutely required, let's have a fixture which will control this (enabling the status code)?

That would be nice.

My use case is to check for status_code.is_success, just to make sure that the page is generated successfully.
This could be achieved (somehow) by assert "" not in browser.html, but using the status_code would be better.

@bubenkoff
Copy link
Member

I'll take a look, thanks
On Jan 18, 2015 6:38 PM, "Daniel Hahler" notifications@github.com wrote:

but this compensation requires an additional request which slows down the
whole test process

Would it be possible to do this extra request lazily, when/if status_code
gets accessed?

if you feel it absolutely required, let's have a fixture which will
control this (enabling the status code)?

That would be nice.

My use case is to check for status_code.is_success, just to make sure
that the page is generated successfully.
This could be achieved (somehow) by assert "" not in browser.html, but
using the status_code would be better.


Reply to this email directly or view it on GitHub
#2 (comment)
.

@blueyed
Copy link
Contributor

blueyed commented Jan 18, 2015

Thanks!
For the time being, please consider re-opening the issue, so that it does not get lost.

@bubenkoff bubenkoff self-assigned this Jan 18, 2015
@bubenkoff bubenkoff reopened this Jan 18, 2015
@bubenkoff
Copy link
Member

1.2.8 is out!

@bubenkoff
Copy link
Member

oops, found out that status_code wasn't cleared on visit, now it's ok
1.2.9 is there, please try

@blueyed
Copy link
Contributor

blueyed commented Feb 4, 2015

Sorry for the late reply, works as advertised! :)
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants