How to find an element by matching exact text of the element in Capybara

Use a regexp instead of a string for the value of the :text key: find(“a”, :text => /\ABerlin\z/) Check out the ‘Options Hash’ section of the Method: Capybara::Node::Finders#all documentation. PS: text matches are case sensitive. Your example code actually raises an error: find(“a”, :text => “berlin”) # => Capybara::ElementNotFound: # Unable to find css “a” … Read more

How to click first link in list of items after upgrading to Capybara 2.0?

You can just use: first(‘.item’).click_link(‘Agree’) or first(‘.item > a’).click (if your default selector is :css) Code in your question doesn’t work as: within “.item” do first(:link, “Agree”).click end is equivalent to: find(‘.item’).first(:link, “Agree”).click Capybara finds several .item‘s so it raises an exception. I consider this behavior of Capybara 2 very good.

How to get current path with query string using Capybara

I’ve updated this answer to reflect modern conventions in capybara. I think this is ideal since this is the accepted answer, and what many people are being referred to when looking for a solution. With that said, the correct way to check the current path is to use the has_current_path? matcher provided by Capybara, as … Read more

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