
|
If you were logged in you would be able to see more operations.
|
|
|
|
Original Estimate:
|
Unknown
|
Remaining Estimate:
|
Unknown
|
Time Spent:
|
Unknown
|
|
Environment:
|
RHEL3, RHEL4, WIndows 2KP, Selenium RC 0.8.x, Perl 5.8.x,
|
|
|
The following code sends an alert to the browser if the user hasn't filled in all the required fields. Please note that it sends multiple messages on separate lines when the user "forgets" to fill in multiple fields.
function checkForm (f) {
var alertMessage="" ;
var checkStatus=true ;
for (i=0;i<registeredFields.length;i++) {
var field=registeredFields[i] ;
if (1 == field.required) {
if ("singleselect" == field.type) {
var fieldValue=f.elements[field.name].value ;
if ("Unspecified" == fieldValue || "" == fieldValue) {
alertMessage += field.description+" is required\n" ;
checkStatus=false ;
}
} else
if ("multiselect" == field.type) {
var selectedIndex=f.elements[field.name].selectedIndex ;
if (-1 == selectedIndex) {
alertMessage += "A valid "+field.description+" is required\n" ;
checkStatus=false ;
}
} else
if ("textinput" == field.type) {
var fieldValue=f.elements[field.name].value ;
if (0 == fieldValue.length) {
alertMessage += field.description+" is required\n" ;
checkStatus=false ;
}
}
}
}
if (false == checkStatus) {
alert (alertMessage) ;
}
return checkStatus ;
}
The problem is, when we simulate forgetting multiple items in Selenium test scripts, get_alert() only reports one of the messages rather than the three we expect.
|
|
Description
|
The following code sends an alert to the browser if the user hasn't filled in all the required fields. Please note that it sends multiple messages on separate lines when the user "forgets" to fill in multiple fields.
function checkForm (f) {
var alertMessage="" ;
var checkStatus=true ;
for (i=0;i<registeredFields.length;i++) {
var field=registeredFields[i] ;
if (1 == field.required) {
if ("singleselect" == field.type) {
var fieldValue=f.elements[field.name].value ;
if ("Unspecified" == fieldValue || "" == fieldValue) {
alertMessage += field.description+" is required\n" ;
checkStatus=false ;
}
} else
if ("multiselect" == field.type) {
var selectedIndex=f.elements[field.name].selectedIndex ;
if (-1 == selectedIndex) {
alertMessage += "A valid "+field.description+" is required\n" ;
checkStatus=false ;
}
} else
if ("textinput" == field.type) {
var fieldValue=f.elements[field.name].value ;
if (0 == fieldValue.length) {
alertMessage += field.description+" is required\n" ;
checkStatus=false ;
}
}
}
}
if (false == checkStatus) {
alert (alertMessage) ;
}
return checkStatus ;
}
The problem is, when we simulate forgetting multiple items in Selenium test scripts, get_alert() only reports one of the messages rather than the three we expect. |
Show » |
|
to make this work in selenium core, I adjusted the code to replace carriage returns with blank spaces. So the test assertion must not include carriage returns itself. This is required because when we express the test case in HTML, the character turns are not retained in the strings retrieved from the test table. I don't consider this to be a significant limitation, however.
Note that this problem was not specific to Perl (or indeed to selenium remote control).