I am totally a newbie to phonegap/cordova application. Basically i have a form in my application and i want to write a script which basically enters the values in the form and keep on doing it with new random values everytime . I have no idea where to begin with . Can somebody please help me with this , so i can atleast start learning how to write automated testing script?
Asked
Active
Viewed 27 times
1 Answers
1
Well, basically you can just take a function like this (by user csharptest.net)
function makeString()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var len = Math.floor((Math.random() * 10) + 1);
for( var i=0; i < len; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
to get random strings. Then you do something like
document.getElementById("form_field1").value = makeString();
document.getElementById("form_field2").value = makeString();
for each of your fields of your form such as
<form id="my_form">
<input type="text" id="form_field1" />
<input type="text" id="form_field2" />
</form>
After setting the values, you can submit the form with
document.getElementById("my_form").submit();

Community
- 1
- 1

Roope Hakulinen
- 7,326
- 4
- 43
- 66