1

i have a (i guess) simple question.

I am running Selenium test cases (HTML, selense) after a successful build in Hudson. The testcases pass when i run them in the IDE after the build but not on the server. The cases that fails holds a regexp expression like so:

regexp:The profile details have been updated, it can take up to [0-9]*\s\w*\(.\) until the changes are fully visible.

the goal is to match times like 1 hour(s), 30 second(s) 4 minutes(s)

Have someone encountered a problem like this and how did you solve it?

SebastianK
  • 55
  • 1
  • 1
  • 7

2 Answers2

1

I would use a slightly simpler expression, assuming you do not need to handle things like 1 second, 2 seconds, etc, but only need to handle things like 1 second(s) or 2 second(s), you could use this expression:

try replacing the regex stuff with

[0-9]+ [a-z]+\(s\)

Some older regex flavors (POSIX ERE) don't allow the shorthand character classes, so if those rules are somehow being invoked, then it would fail on \s and \w (and maybe even the .). The above expression should work almost anywhere; though it is not as flexible, it should be flexible enough for your situation.

Some flavors that are even older (POSIX BRE) don't support the shorthand repetition and actually interpret curly braces and parentheses differently as well. If that is the flavor being expected, it might just fail on any normal expression, and you'd need to usde something like:

[0-9]\{1,\} [a-z]\{1,\}(s)

If neither of these work, then there is a significant difference in the engines implementing your regex OR there is some difference in how the page is rendering and being parsed/searched/analyzed by the Selenium Server.

If that is the case, there could be <br> tags or formatting tags (like <i> or <span>) that are being parsed as text rather than being extracted from the string. Then, something like changes are fully visible might be parsed as changes are <em>fully</em> visible and thus failing the test

Code Jockey
  • 6,611
  • 6
  • 33
  • 45
  • 1
    @SebastianK If you're interested, a good intro-to-comprehensive tutorial website for regex is at [regular-expressions.info](http://regular-expressions.info/) - it's where I learned 90% of what I know about regex! – Code Jockey Nov 11 '11 at 14:51
0

When you test it locally versus hudson run, are there differences in OS platform?

I know that I had some problems with windows xp versus unix (where hudson was deployed). Although I don't think that is the case here, just a thought though.

fredde
  • 62
  • 1
  • 1
  • 7
  • No, they are both run on Mac OS X. Snow leopard and i think the server is running lion. – SebastianK Nov 08 '11 at 10:04
  • Selenium's "regexp:" isn't platform specific, but it **can be** browser specific. In particular, it uses the browsers JavaScript RegExp implementation to do the matching. – Ross Patterson Nov 08 '11 at 14:45
  • Ok, good point, I id not know that. What I was working with was not related to selenium, but I forgot to mention that. – fredde Nov 08 '11 at 15:01