Unkas
Unkas

Reputation: 3710

how to make phantomjs gem not to ignore browser validations while testing

I use phantomjs gem to run my feature tests.

But when I ask test to leave empty required fields and then to press Submit button - it runs into controller for some reason.

Of course, when I do it manually in browser - I get a 'field can not be empty' without server request.

How can I fix it and make phantom js to respect a client validators?

    ActiveRecord::RecordInvalid:
       Validation failed: Email can't be blank, Password can't be blank, First name can't be blank, Last name can't be blank, Phone number can't be blank, Access parameter should be an admin for first company employee
     # ./app/controllers/employees/registrations_controller.rb:25:in `create'

Upvotes: 0

Views: 36

Answers (1)

Thomas Walpole
Thomas Walpole

Reputation: 49870

PhantomJS hasn’t been updated in years and is currently equivalent to an 8 year old version of Safari. That means it most likely doesn’t support HTML form validation and a lot of other JS/CSS technologies used by modern sites/apps. You need to move to using selenium with headless Chrome or one of the direct to chrome via CDP (https://github.com/twalpole/apparition , etc) drivers for your testing

Upvotes: 1

Related Questions