-
Notifications
You must be signed in to change notification settings - Fork 62
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
No more detailed error messages since 1.4.2 #64
Comments
The mentioned commit was part of #58 PR and it really does what it says it does: masks any WebDriver response with non 200 code as HTTP error response with not much details. I personally prefer exception from underlying libraries (the WebDriver in this case) to bubble up so that you see exactly what went wrong instead of masking them with transport-layer (HTTP in this case) specific exceptions. The easiest solution would be to revert mentioned commit, but I'm not sure what problem @gggeek was attempting to solve with it to be certain. |
Hello. I am not very knowledgeable about the selenium protocol, but I would have expected selenium to return to the testing app any error of the type 'I can not execute your desired command' in other ways than via http error responses (this is a bit of a misfeature often implemented by designers of rest apis, where application errors and transport errors are mixed). My fix was intended to not have any impact on any 'seleniun said that app or browser are misbehaving' error; if that is not the case, it can be rolled back and implemented in a better/safer way. As for the bubbling/masking of exceptions: I fully agree with your general principle of bubbling up exceptions. In fact my fix intended to do just that: bubble up the faulty connection to selenium which was masked as 'element not found' error. It is just that the POV is reversed: the http layer sits below the the underlying libraries, not above :-D |
ps @m0ppers are you sure that your errors 500 are due to the element not being present in the page? |
Yes: <html>
<body>
<button style="display:none" id="b">bbb</button>
</body>
</html> This is a minimal, constructed testcase to reproduce the problem of not reporting the problem ;). Just had a look at the spec: https://w3c.github.io/webdriver/webdriver-spec.html#handling-errors It seems they are using status code 500 to report back expected error messages like "out of bounds" etc. This seems wrong to me as well. 500 should be "wow something really unexpected is happening. Bailing out" whereas "element is not visible" is an expected error :s maybe it is possible to distinguish between your proxy errors and expected webdriver errors? |
Aha, it starts to make sense. The doc you linked to is better than the one I looked at (mentioned in the webdriver sources): https://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes - from that one one could infer that selenium would send back an http-200 response with a json body with an error code in it, whereas reality is that selenium sends back a 4xx or 5xx response with a json body. I'd say that, missing a hard rule, we can reach a reasonable separation between 4xx/5xx errors generated by selenium and unintentional ones with the following rule of thumb:
what do you think? we would have to validate against different selenium versions of course, the oldest the merrier |
The https://github.com/instaclick/php-webdriver/blob/master/lib/WebDriver/Exception.php class actually transforms internal JSONWire protocol errors (0 - 34), that @gggeek mentioned to actual exceptions, that are thrown in https://github.com/instaclick/php-webdriver/blob/master/lib/WebDriver/AbstractWebDriver.php#L140. Unfortunately it seems, that the internal JSON Wire error is also mapped to HTTP response code according to @m0ppers document. Before #58 merge it worked like a charm. Maybe @gggeek was using |
Then I'd go for having CurlService throw exceptions on http errors (ie. keep it generic), and change AbstractWebDriver to catch the exceptions and properly decode them. Would you agree? |
👍 |
Sounds good. Can someone submit a PR? (I'm in meetings all day.) |
I can do, but most likely not before saturday |
👍 . If possible, then please also create a test to prove that this behavior (proper error is reported back) is working as well. I guess we need to mock both |
Here's the work in progress: https://github.com/gggeek/php-webdriver/tree/issue_57_bis. It is not finished, but I thought you might want to validate the approach taken. Besides the changes in the curl service, I am in the process of adding functional tests - no mock objects but rather a quick install of selenium + apache on Travis. In my opinion this gives more reliable results than plain unit tests when you have to debug http connetions between different apps. |
You can send PR anyway, but add |
PR sent. The code has been reworked a bit. The changes are less intrusive now (no more throwing of exceptions on errors 4xx/5xx from Selenium to be caught immediately after, that is left as optional and is activated by the saucelabs client; the abstractwebdriver does instead more checking of the results). There might be travis failures, as I introduced some changes to the Travis set up, but I know of no other way to debug Travis errors than to push to GitHub ;-) |
PS: side note: after a lot of reading and head scratching, it seems that the protocol described by the w3c (https://w3c.github.io/webdriver/webdriver-spec.html#the-webdriver-interface) is quite different from the one implemented by current selenium. And I changed my mind about it being more clear to understand - in fact it does not seem to correct the warts of the original, but gets even more obfuscated in its wording... :-O |
Ok, managed to appease Travis. Functional testing fully available now :-) It just has to be seen which version of Selenium to test against. Ideally we could pick a different selenium version for each php version, to get broader coverage... |
I finally got around to reviewing and leaving feedback on the PR. WRT Selenium server versions, the php version is less of a concern that what Firefox version is installed since Selenium server releases lag behind Firefox updates. If we can't control which versions of Firefox+Selenium are installed for CI testing, then the tests have to be disabled. |
@robocoder thanks for the review, will apply changes. I can try to come up with a test matrix for Travis with different selenium versions (but Firefox is going to be harder). Any list of specific versions to start with? |
Travis allows you to install any firefox version you need. In worst case scenario we can use SauceLabs or BrowserStack free tier for open source projects to test on different browser versions. |
I have investigated the correspondence between Firefox versions and Selenium versions. This currently means: I can pin down these versions in travis.yml if you agree. Otoh, I did not find a way to have different FF versions installed by Travis when doing a test matrix. |
Is this still relevant, because we reverted originally mentioned commit that was hiding the error message? |
@aik099 yes it is. The revert of my bad commit means that currently:
|
I am using the webdriver in combination with behat. Since the release of 1.4.2 we are getting unusable error messages from the php web-driver
Example:
This is not helpful at all. When i am locking the php-webdriver to 1.4.1 the same test does the following:
This is (my) desired result here.
I debugged a bit and can track down the error to this commit:
3b11d17
When removing this line everything is working again. I am not into the internals and don't know what problem that commit exactly solved but it makes debugging behat results nearly impossible as there are no error details at all anymore 🍶
The text was updated successfully, but these errors were encountered: