capybara assert attributes of an element

Another simple solution is to access the HTML attribute you are looking for with []: find(‘#my_element’)[‘class’] # => “highlighted clearfix some_other_css_class” find(‘a#my_element’)[‘href’] # => “http://example.com # or in general, find any attribute, even if it does not exist find(‘a#my_element’)[‘no_such_attribute’] # => “” Note that Capybara will automatically try to wait for asynchronous requests to finish, … Read more

undefined method `visit’ when using RSpec and Capybara in rails

Try to add: config.include Capybara::DSL to your config block. # This file is copied to spec/ when you run ‘rails generate rspec:install’ ENV[“RAILS_ENV”] ||=”test” require File.expand_path(“../../config/environment”, __FILE__) require ‘rspec/rails’ require ‘rspec/autorun’ # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join(“spec/support/**/*.rb”)].each {|f| require f} RSpec.configure do |config| … Read more

How to get parent node in Capybara?

I really found jamuraa’s answer helpful, but going for full xpath gave me a nightmare of a string in my case, so I happily made use of the ability to concatenate find’s in Capybara, allowing me to mix css and xpath selection. Your example would then look like this: find(‘#some_button’).find(:xpath,”.//..”).fill_in “Name:”, :with => name Capybara … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)