I would like to do a single HTTPS POST to a server using Selenium IDE with an XML payload. The service I'm interacting with doesn't support HTTPS GETs or I would do it that way. (Doing an HTTPS GET is really easy as the whole URL goes into a Selenium open command.) I know there are other ways to do HTTP POSTs such as with curl, but my web testing is currently done in Selenium IDE and I don't want to have to worry about two or three different tools to do my testing.
I looked into POST submission by Javascript and modified the code I found there. I put it in as a storeEval command in Selenium IDE. The final version of the code is below:
var method = method || "post";
var path = "https://service.url.srv/";
var post = "<xml>payload</xml>";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "");
hiddenField.setAttribute("value", post);
form.appendChild(hiddenField); form.submit();
When I ran a slightly modified version of the example code, I got a message in the Selenium IDE log saying that "document.body is undefined". I tried removing all references to document.body, hoping that a simple form object by itself would be enough. It wasn't. I got "form.submit is not a function". Perhaps there is some Javascript mojo that will work.
I haven't found any references on Google or StackOverflow where someone is trying to do a HTTP POST in Selenium IDE. I'm willing to write an extension to Selenium if doing a POST is even possible.