Watir and regexp

We want to test a value given in a text field with a regular
expression. We are trying to do it this way:

@browser.text_field(:name,“vareeier”).set(“123456789”)
@browser.text_field(:name,“vareeier”).value.should_equal(/[0-9]{9}/)

This is not working for us. We also tried using
@browser.text_field(:name,“vareeier”).value.matches(/[0-9]{9}/)
@browser.text_field(:name,“vareeier”).verify_contains(/[0-9]{9}/)

None of these work.
Help…

[email protected] wrote:

None of these work.
Define “work”. Have you take the step of creating a test regex that must
succeed, in order to eliminate syntax errors other than regex ones?

Help…

I can’t help you with any Watir syntax issues that may be present, but
the
regex would be better written as:

/^\d{9}$/

This assures that nine consecutive digits are all that is present in the
field. Your original regex only assured that nine consecutive digits
were
present somewhere in a field that could contain an arbitrary amount of
other data.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs