This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
RegExps are not currently a supported type. When Selenium WebDriver encounters them in this context it will convert them to an empty object. I'm not certain if there are cross-platform issues with this, but AFAIK RegExp is broadly supported so should be a decent candidate for this.
While RegExp would be awesome unfortunately there is no way to serialize a Regexp to JSON. YOu can still create your own execute_script and pass it the string that has a regexp.
Well sure there is, if we wanted to support this: {some-defined-uuid: string-that-compiles-as-regexp} (I don't have an opinion on whether this should be supported, but it is certainly *possible* to do so).
Right, this is the sort of thing I have in my client code to work around this. Makes for some ugliness and repetition in the client code... like so: // test/driver side if (Object.prototype.toString.call(mockDef.url) == '[object RegExp]') { // Serialize RegExp with special prefix flag mockDef.url = REGEXFLAG + mockDef.url.source; } /*/*/*/*/ // browser side if (mockDef.url.indexOf(REGEXFLAG) === 0) { // Marshal RegExp from special string mockDef.url = new RegExp(mockDef.url.substr(3)); } Ugly, and of course the REGEXFLAG constant needs to be defined on both sides as well.