I'm testing views with Cucumber and Rails right now and really enjoy the experience. I can easily say:
Background: Given I am logged in as a customer Scenario: View the Welcome Page When I go to the home page Then I should be on the "Welcome" page And I should see the following in the sidebar: | selector | text | | h3 | Search | | .home-page | Home | | .about-page | About |
Now I wonder how I can go further and say:
And I should see the following colors on the "Welcome" page: | selector | background | |
It seems to me that I saw that you can do this with something like Node.js or another serveride javascript, because it depends on the browser. Is there a way to do this, maybe with Selenium only in Safari and Firefox?
I just want to test mainly colors and fonts, and not necessarily the b / c layout of the crazy cross browser. How can i do this? Maybe a little Jasmine with a cucumber ?
Thanks!
Update
Thanks to @idlefingers, something works here:
Setting: cucumber, capybara.
functions / support / env.rb:
Capybara.javascript_driver = :selenium
* functions / step _definitions / css_steps.rb: *
Then /^I should see the color "([^"]+)" on the ([^"]+)$/ do |color, selector| element_color = page.evaluate_script('$("##{selector}").css("border-left-color");')
functions / some.feature:
And I should see the color "red" on the sidebar
If there is a better way, I would love to know!
css ruby-on-rails tdd selenium
Lance pollard
source share