Code Monkey home page Code Monkey logo

Comments (14)

flavianmissi avatar flavianmissi commented on July 17, 2024

Based on this issue, I think that selenium webdriver does not support this functionality. I have an alternative for this problem, but I don't know if it is the best solution. Another solution is to use a proxy, like this one.
What do you think?

from splinter.

andrewsmedina avatar andrewsmedina commented on July 17, 2024

Yes, selenium/webdriver does not support this functionality, I like your proposal, and I think that splinter will be works with any http exceptions, like 500, 404, etc.

What do you think?

from splinter.

flavianmissi avatar flavianmissi commented on July 17, 2024

Yeah, with this solution splinter will be able to work with any http status code.

I'll finish my code and make a pull request. ;D

from splinter.

rennerocha avatar rennerocha commented on July 17, 2024

It'll be nice if we can check any status code returned, not only 404.

from splinter.

flavianmissi avatar flavianmissi commented on July 17, 2024

Hey!
Should splinter stop it's process completely when it gets a http error?
Because now I'm raising an exception, which makes the test break and doesn't even open the page, what do you think about it, is this enough?

from splinter.

fsouza avatar fsouza commented on July 17, 2024

Which info do you provide in the exception? Are you raising an unique exception for all errors or one exception per error?

from splinter.

flavianmissi avatar flavianmissi commented on July 17, 2024

Yes I'm using an unique exception; I created a HttpResponseError exception, but when I raise it I pass the reason phrase returned by httplib, so if you try to access a page and get an 404 status code, you'll have an exception with the text "404 - Not Found"
So?

from splinter.

fsouza avatar fsouza commented on July 17, 2024

IMHO, HttpResponseError should encapsulate two attributes: status_code and reason.

Here is an example:

try:
    browser = Browser("webdriver.firefox")
    browser.visit("http://google.com.br/not_found_at_google")
except HttpResponseError as e:
    print "I have failed :( Status code: %d. Reason: %s" %(e.status_code, e.reason)
    # will print "I have failed :( Status code: 404. Reason: Not found

from splinter.

fsouza avatar fsouza commented on July 17, 2024

I merged the pull request and Splinter has this feature now, but we need docs, so I'm keeping this issue opened.

from splinter.

flavianmissi avatar flavianmissi commented on July 17, 2024

I'm closing that issue, since docs are written. ;)

from splinter.

fsouza avatar fsouza commented on July 17, 2024

What about fix the problem with non-HTTP protocols? :P

from splinter.

flavianmissi avatar flavianmissi commented on July 17, 2024

Yeah, you're right!
But I thought that maybe this could be another issue... I really don't know... ;)
What you think?

from splinter.

flavianmissi avatar flavianmissi commented on July 17, 2024

As @FranciscoSouza and I talked, I have already opened another issue, so I'm closing that.

from splinter.

CharString avatar CharString commented on July 17, 2024

How can I test if my 404 page is working correctly?
Is there any way I can expect a 404 and test its contents?

If I catch the exception I end up with browser.html containing the previous 200 page.

from splinter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.