History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SRC-452
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Nelson Sproul
Reporter: Kevin Benton
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Selenium Remote Control

Calls to get_alert() in Perl (calls getNextAlert in js) unable to render full alert when alert contains "\n" in it.

Created: 25/Mar/08 12:35 AM   Updated: 08/May/08 03:18 AM
Component/s: JS Runner, Client Driver - Perl
Affects Version/s: 0.8.1
Fix Version/s: 1.0

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: RHEL3, RHEL4, WIndows 2KP, Selenium RC 0.8.x, Perl 5.8.x,


 Description  « Hide
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.

 All   Comments   Work Log   Change History      Sort Order:
Nelson Sproul - 04/Apr/08 07:24 PM
fixed by updating selenium core in revision 2041.

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).

Shinya Kasatani - 08/May/08 03:18 AM
As I mentioned here, I think we should revert fixes in r2040 and r2041 because Selenium Core did actually support newline characters in alerts using BR tags.

http://clearspace.openqa.org/thread/13368

I've also confirmed that get_alert in Perl driver does return newline characters in alerts correctly using a code like this with Selenium RC 1.0 beta-1.

HTML code:
<li><a href="#" onclick="alert('A message\nwith multiple spaces')">show alert with multiple spaces</a></li>

Perl code:
$sel->click_ok("link=show alert with multiple spaces");
$sel->alert_is("A message\nwith multiple spaces");