Chris Hoy wrote:

> How do I get verifyConfirmation to just verify that a dialog was
> generated and not that the text matches a specific value. I don't
> want to verify the contents as it been generated on the fly in the
> javascript and is complex

User extensions are below.
With them you can do:

click             | linkThatProducesAlert  |
verifyAlertMatch  | /.+/gi                 |


----------------------------------
//  Asserts that the alert message was received and it matches the pattern
Selenium.prototype.assertAlertMatch = function( pattern ) {
   if ( this.browserbot.hasAlerts()) {

       var receivedAlert = this.browserbot.getNextAlert();

       var re = regex_from_text( pattern );

       if ( !re.test( receivedAlert ) ) {
          assert.fail("The alert [" + receivedAlert + "] did not match the
RegExp: " + pattern );
       }

   } else {
       assert.fail("There were no alerts");
   }
};


// Asserts that the confirmation message was received and it matches the
pattern
Selenium.prototype.assertConfirmationMatch = function( pattern ) {
   if ( this.browserbot.hasConfirmations()) {

       var receivedConfirmation = this.browserbot.getNextConfirmation();

       var re = regex_from_text( pattern );

       if ( !re.test( receivedConfirmation ) ) {
          assert.fail("The confirmation message [" + receivedConfirmation +
"] did not match RegExp: " + pattern );
       }

   } else {
       assert.fail("There were no confirmations");
   }
};



function regex_from_text( txt )
    {
    var re = /^\/(.+)\/([gim]*)$/;
    var arr = txt.match( re );

    if( arr.length < 3 )
        {
        assert.fail( "regex_from_text: could not create regexp" );
        return;
        }

    return new RegExp( arr[1], arr[2] )
    }


------------------------------
Andrey Yegorov
MetaCommunications Engineering


_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users

Reply via email to