Comments (14)
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.
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.
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.
It'll be nice if we can check any status code returned, not only 404.
from splinter.
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.
Which info do you provide in the exception? Are you raising an unique exception for all errors or one exception per error?
from splinter.
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.
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.
I merged the pull request and Splinter has this feature now, but we need docs, so I'm keeping this issue opened.
from splinter.
I'm closing that issue, since docs are written. ;)
from splinter.
What about fix the problem with non-HTTP protocols? :P
from splinter.
Yeah, you're right!
But I thought that maybe this could be another issue... I really don't know... ;)
What you think?
from splinter.
As @FranciscoSouza and I talked, I have already opened another issue, so I'm closing that.
from splinter.
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)
- π From the Selenium project!
- attach_file work with flask? HOT 2
- Browser raise NoneType HOT 7
- CanΒ΄t find Iframe HOT 1
- Integration of undetected-chromedriver
- Changelog: Single file? HOT 3
- 'NoneType' object is not callable HOT 2
- We noticed regressions and inconsistencies after migrating from 0.18.1 to 0.19.0 HOT 9
- Cannot send characters directly to the browser HOT 2
- Config cannot be imported HOT 5
- Parallel script execution HOT 2
- Exception when using the latest Selenium HOT 3
- Existing profile is not loaded HOT 3
- selenium.WebDriver no longer accepts desired_capabilities as a kwarg HOT 1
- ValueError: I/O operation on closed file HOT 3
- More type annotations? HOT 1
- Constant error on startup HOT 2
- Launch the browser hidden HOT 1
- Testing and tox.ini environment improvements
- Splinter tests not failing when element not found on the page and wait_time set to 1 second HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splinter.