suddenzero
Programmer
Hello Everyone Smarter Than Me!
Before I get to the question first a little History on what I am working with. I am a Software Engineer currently working under a contract in a highly customized environment. The IDE that I am using (Not by my choice as I am a Java developer by Trade) uses a "JavaScript Runtime Environment" to treat JavaScript as a complied language. Needless to say this is a little odd and it was created because my employer had trouble finding enough developers that know other languages (This also seems odd) but there always seemed to be a ton of JavaScript people around.
Anyway now to the question. The code I am writing is product testing automation code that is going to save testing dollars eventually. Initially the testing was done by a team of testers whom would log into a website, run some tests by interacting with the website, and then get the results from the tests via the product that they are testing.
My code will do all the interaction with the device and the website and then compile all the results in an Ms. Excell spreadsheet for viewing. The problem is that my employer doesn't own the website that the testing is done from and there has been some changes lately that I am trying to overcome.
The problem is as follows.
I have been using a Microsoft.XMLHTTP ActiveX Object to login to the website and do all the test manipulation and form submitting. The recent changes to the website have broken the automation code. The original form that I was working with contained a submit button as follows
<input id="submitReq" type="submit" value="task device"/>
and the id allowed the ActiveX control to find the button and submit the form.
Now the page has changed as follows.
There is no longer a submit button instead there is a standard button calling a javascript onclick which is then used to submit the form. The button and the javascript are below and as you can see the button has no id which makes finding and submitting the button very difficult.
Can anyone tell me how to submit this page after the form is filled out using the Microsoft.XMLHTTP ActiveX Object? Is there a way?
Thanks in advance for any help that any of you can be.
Regards,
Before I get to the question first a little History on what I am working with. I am a Software Engineer currently working under a contract in a highly customized environment. The IDE that I am using (Not by my choice as I am a Java developer by Trade) uses a "JavaScript Runtime Environment" to treat JavaScript as a complied language. Needless to say this is a little odd and it was created because my employer had trouble finding enough developers that know other languages (This also seems odd) but there always seemed to be a ton of JavaScript people around.
Anyway now to the question. The code I am writing is product testing automation code that is going to save testing dollars eventually. Initially the testing was done by a team of testers whom would log into a website, run some tests by interacting with the website, and then get the results from the tests via the product that they are testing.
My code will do all the interaction with the device and the website and then compile all the results in an Ms. Excell spreadsheet for viewing. The problem is that my employer doesn't own the website that the testing is done from and there has been some changes lately that I am trying to overcome.
The problem is as follows.
I have been using a Microsoft.XMLHTTP ActiveX Object to login to the website and do all the test manipulation and form submitting. The recent changes to the website have broken the automation code. The original form that I was working with contained a submit button as follows
<input id="submitReq" type="submit" value="task device"/>
and the id allowed the ActiveX control to find the button and submit the form.
Now the page has changed as follows.
There is no longer a submit button instead there is a standard button calling a javascript onclick which is then used to submit the form. The button and the javascript are below and as you can see the button has no id which makes finding and submitting the button very difficult.
Code:
<input type="button" class="button" value="Task Devices" onclick="submitRequestForm()"/>
<script type="text/javascript">
<![CDATA[
function submitRequestForm()
{
var validations = new Object();
var fieldNames = ["devices", "profile", "priority"];
for (var key in fieldNames) {
try
{
document.getElementById("errorMessageSpace_" + fieldNames[key]).innerHTML = "";
}
catch(ex)
{
}
}
validations["devices"] = [
{type: "required", errorAction: displayTaskingParamError, errorMsg: "Devices field cannot be empty!"},
{type: "mask", regExp: /^(([!]?[\+]?([*?0-9A-Fa-f]{0,30}))|(([!]?[\+]?[0-9A-Fa-f]{0,30})?\/([0-9A-Fa-f]{0,30})?\/([*?0-9A-Fa-f]{0,30})?))(\s(([!]?[\+]?([*?0-9A-Fa-f]{0,30}))|(([!]?[\+]?[0-9A-Fa-f]{0,30})?\/([0-9A-Fa-f]{0,30})?\/([0-9A-Fa-f]{0,30})?)))*$/, errorAction: displayTaskingParamError, errorMsg: "Invalid devices list specification!"}];
validations["profile"] = [
{type: "required", errorAction: displayTaskingParamError, errorMsg: "Profile field cannot be empty!"},
{type: "mask", regExp: /^[0-9]*$/, errorAction: displayTaskingParamError, errorMsg: "Invalid profile specification!"}];
validations["priority"] = [
{type: "required", errorAction: displayTaskingParamError, errorMsg: "Priority field cannot be empty!"},
{type: "mask", regExp: /^[+-]?[0-9]*$/, errorAction: displayTaskingParamError, errorMsg: "Invalid priority specification!"},
{type: "numberBetween", low: 0, high: 1000, errorAction: displayTaskingParamError, errorMsg: "Priority value must be between 0 and 1000!"}];
var taskingRequestForm = document.getElementById('taskingForm');
taskingRequestForm.elements["devices"].value = normalizeDevicesList(taskingRequestForm.devices.value);
if (new FormValidator(taskingRequestForm, validations).validate(false))
{
taskingRequestForm.submit();
}
}
function displayTaskingParamError(field, validation)
{
try
{
document.getElementById("errorMessageSpace_" + (field.name || field.id)).innerHTML = "*" + validation["errorMsg"];
}
catch(ex)
{
alert(validation["errorMsg"]);
}
}
]]>
</script>
Can anyone tell me how to submit this page after the form is filled out using the Microsoft.XMLHTTP ActiveX Object? Is there a way?
Thanks in advance for any help that any of you can be.
Regards,