Capybara method and matchers which is frequently used

testcapybararails
tomoyukikashiro
tomoyukikashiro

method

fill with value in input

fill_in("name value", with: "value")

click button

click_button("submit")

find element

find("#selector")

select select tag option

select("japan", :from => "country")

access page

visit("/page/path")

change host

Capybara.app_host = "http://example.com"

matchers

expect(page).to have_title("page title")
expect(page).to have_link("link text", :href => "/path")
expect(page).to have_content("content text")
expect(form).to have_selector(:css, "[name='email']", visible: true)