Problem getting cucumber scenario with selenium and xhr post to work
I have a cucumber scenario that test an xhr post which returns some js 开发者_JAVA百科code which is used to modified the page.
The problem I'm having is that when I test it manually it works perfectly both in FF or Chrome, but when I run it with cucumber and selenium it is not working (with firefox). I did some debugging and I'm getting the js answer correctly, but it is not being executed since it doesn't modified the page as need.
I'm using jquery sexy post and the part that is in charge of executing the response is in:
if (config.autoclear && (xhr.status >= 200) && (xhr.status <= 204)) clearFields(form);
form.trigger("sexyPost.complete", [xhr.responseText]);
It seems that form.trigger("sexyPost.complete", [xhr.responseText]); is not being executed, if I put an alert like:
alert(xhr.responseText);
I can confirm that the answer is indeed the correct one.
Has someone had a similar problem before?.
UDPATE
I figure it out that the trigger was being executed, though what it isn't is the call to eval.
eval(xhr.responseText);
Try changing from POST to GET. I had the same issue running Selenium and PantomJS. Using $.ajax() with POST always returned a httpstatus of 200. When I changed to GET, I got the correct status codes.
精彩评论