[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/test_tools/selenium/core/scripts/ -> se2html.js (source)

   1  /*
   2  
   3  This is an experiment in creating a "selenese" parser that drastically
   4  cuts down on the line noise associated with writing tests in HTML.
   5  
   6  The 'parse' function will accept the follow sample commands.
   7  
   8  test-cases:
   9      //comment
  10      command "param"
  11      command "param" // comment
  12      command "param" "param2"
  13      command "param" "param2" // this is a comment
  14  
  15  TODO: 
  16  1) Deal with multiline parameters
  17  2) Escape quotes properly
  18  3) Determine whether this should/will become the "preferred" syntax 
  19     for delivered Selenium self-test scripts
  20  */    
  21  
  22  
  23  function separse(doc) {
  24      // Get object
  25      script = doc.getElementById('testcase')
  26      // Split into lines
  27      lines = script.text.split('\n');
  28  
  29  
  30      var command_pattern = / *(\w+) *"([^"]*)" *(?:"([^"]*)"){0,1}(?: *(\/\/ *.+))*/i;
  31      var comment_pattern = /^ *(\/\/ *.+)/
  32  
  33      // Regex each line into selenium command and convert into table row.
  34      // eg. "<command> <quote> <quote> <comment>"
  35      var new_test_source = '';
  36      var new_line        = '';
  37      for (var x=0; x < lines.length; x++) {
  38          result = lines[x].match(command_pattern);
  39          if (result != null) {
  40              new_line = "<tr><td>" + (result[1] || '&nbsp;') + "</td>" +
  41                             "<td>" + (result[2] || '&nbsp;') + "</td>" +
  42                             "<td>" + (result[3] || '&nbsp;') + "</td>" +
  43                             "<td>" + (result[4] || '&nbsp;') + "</td></tr>\n";
  44              new_test_source += new_line;
  45          }
  46          result = lines[x].match(comment_pattern);
  47          if (result != null) {
  48              new_line = '<tr><td rowspan="1" colspan="4">' +
  49                         (result[1] || '&nbsp;') +
  50                         '</td></tr>';
  51              new_test_source += new_line;
  52          }
  53      }
  54  
  55      // Create HTML Table        
  56      body = doc.body
  57      body.innerHTML += "<table class='selenium' id='testtable'>"+
  58                        new_test_source +
  59                        "</table>";
  60  
  61  }
  62  
  63  


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7