Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Capybara
- =================
- Matchers
- --------
- ```ruby
- have_button(locator)
- have_checked_field(locator)
- have_css('p#foo', :count => 4)
- have_css('li', :text => 'Horse', :visible => true)
- have_field('Name', :with => 'Jonas')
- have_field('Email', :type => 'email')
- have_link(locator, options = {})
- have_select('Language', :selected => 'German')
- have_select('Language', :selected => ['English', 'German'])
- have_select('Language', :options => ['English', 'German', 'Spanish'])
- have_select('Language', :with_options => ['English', 'German'])
- have_selector('p#foo')
- have_selector(:xpath, './/p[@id="foo"]')
- have_selector(:foo)
- have_selector('p#foo', :count => 4)
- have_selector('li', :text => 'Horse', :visible => true)
- have_table('People', :rows => [['Jonas', '24'], ['Peter', '32']])
- have_text(content)
- have_content(content)
- have_unchecked_field?(locator)
- have_xpath('.//p[@id="foo"]')
- have_xpath('.//p[@id="foo"]', :count => 4)
- have_xpath('.//li', :text => 'Horse', :visible => true)
- ```
- Actions
- -------
- ```ruby
- attach_file(locator, path)
- page.attach_file(locator, '/path/to/file.png')
- check(locator)
- page.check('German')
- choose(locator)
- page.choose('Male')
- click_button(locator)
- click_link(locator)
- click_link_or_button(locator) (also: #click_on)
- fill_in(locator, options = {})
- page.fill_in 'Name', :with => 'Bob'
- select(value, options = {})
- page.select 'March', :from => 'Month'
- uncheck(locator)
- page.uncheck('German')
- unselect(value, options = {})
- page.unselect 'March', :from => 'Month'
- ```
- Session
- -------
- ```ruby
- current_host
- current_path
- current_url
- evaluate_script(script)
- execute_script(script)
- html
- reset! # (also: #cleanup!, #reset_session!)
- response_headers # Returns a hash of response headers.
- save_and_open_page
- save_page
- source # (also: #body)
- status_code
- visit(url)
- within(*args)
- within_fieldset(locator)
- within_frame(frame_id)
- within_table(locator)
- within_window(handle, &blk)
- ```
- Finders
- -------
- ```ruby
- all([kind], locator, options)
- all(:css, 'a#person_123')
- all(:xpath, '//a[@id="person_123"]')
- all("a#person_123")
- all('a', :text => 'Home')
- all('#menu li', :visible => true)
- find('#foo').find('.bar')
- find(:xpath, '//div[contains(., "bar")]')
- find('li', :text => 'Quox').click_link('Delete')
- find_button(locator)
- find_by_id(id)
- find_field(locator) # aka field_labeled
- find_link(locator)
- first([kind], locator, options)
- ```
Add Comment
Please, Sign In to add comment