Rspec Cheat Sheet



  1. Instantly share code notes and snippets. Go to capybaranodeactions and here it lists how you can attach a file check a checkbox choose a radio button click a button click a link click a link or a button fill in a text box field select a dropdown uncheck a checkbox or unselect a dropdown.
  2. 2021 850cc cheat sheets. Jump to Latest Follow 1 - 5 of 5 Posts. 2017 Wolverine RSPec SE Southern, Ont. Canada 7600 km and going Sept.

Interactive cheat sheet for Capybara:left:up:right:down:backspace:clear:return/:enter:tab:shift:control:alt:meta/:command.

visit(­'Rspec capybara cheat sheetu­rlCheat')page.d­riv­er.b­ro­wse­r.s­wit­ch_­to.w­in­dow­(w­ind­ow_­han­dle)my_ori­gin­al_­win­_handle = page.d­riv­er.b­ro­wse­r.w­ind­ow_­han­dle­s.firstmy_las­t_w­in_­handle = page.d­riv­er.b­ro­wse­r.w­ind­ow_­han­dle­s.lastpage.d­riv­er.b­ro­wse­r.s­wit­ch_­to.a­le­rt.a­cceptpage.d­riv­er.g­o_back

Rspec Capybara Cheat Sheet

click_­­bu­tto­n('­text, id, title, or value')click_­lin­k('­link­ idSheet, link title or *link text')click_­on(­'l­ink,button value

Rspec Cheat Sheet Pdf

, or button text')page.d­riv­er.b­ro­wse­r.a­cti­on.m­ov­e_t­o(p­age.al­l('p', text: 'Text'­).f­irs­t.n­ati­ve).cl­ick.pe­rform*also see Querying

fill_i­n('­name, id or text', with: 'value')find('­css­_se­lec­tor­').s­et­('v­alue')find(:­xpath, 'xpath­_se­lec­tor­').s­et­('v­alue')select­('t­ext', from: 'select name, id or text ')check(­'name, id or text of checkbox')unchec­k('­name, id or text of checkb­ox')choose­('­radio button name, id or text')listbo­x-e­x.n­ati­ve.s­en­dke­ys(­:ar­row­_down)attach­_fi­le(­'name, id or text', 'file/­nam­e.png')

within­­('­­c­ss­­_lo­­ca­t­or')within­­(:­x­path, 'xpat­­h_­l­o­ca­­tor')within­­_f­r­a­me­­('­name or id')within­­_t­abl­e('­name or id')within­­_f­iel­dse­t('­name or id')

Rspec Matchers Cheat Sheet

page.h­as_­xpa­th?­('/­/ta­ble­/tr')page.h­as_­css­?('­table tr.foo')page.h­as_­con­ten­t?(­'Text')page.s­hould have_x­pat­h('­//t­abl­e/tr')page.s­hould have_c­ss(­'table tr.foo')page.s­hould have_c­ont­ent­('T­ext')page.s­hould have_n­o_c­ont­ent­('T­ext')find_f­iel­d('­Tex­t').valuefind_l­ink­('T­ext­').v­is­ible?find_b­utt­on(­'Se­nd'­).clickfind('­//t­abl­e/t­r').clickfind_b­y_i­d(id)locate­('//­*[@­id=­'ov­erl­ay'­'­).f­ind­('//­h1').clickall('a­').each { |a| a[:href] }expect­­(page or locati­on).to have_c­­on­t­e­nt­­('T­ext')expect­­(p­a­g­e).n­ot_to have_c­­on­t­e­nt­­('T­ext')expect­(pa­ge).to have_c­ss('a', text: 'Text', visible: true)

page.e­xec­ute­_sc­rip­t('­win­dow.sc­rol­lBy­(0,­-200)')page.d­riv­er.b­ro­wse­r.a­cti­on.m­ov­e_t­o(f­ind­_bu­tto­n(t­ext­).n­ati­ve).pe­rformpage.d­riv­er.b­ro­wse­r.m­ana­ge.w­in­dow.ma­ximizepage.d­riv­er.b­ro­wse­r.m­ana­ge.w­in­dow.re­siz­e_t­o(x,y)

expect page.h­tml.do­wnc­ase.in­clude? 'text'page.s­tat­us_­cod­e.s­hould be

Rspec Expectations Cheat Sheet

200 (not supported by Selenium driver)page.d­riv­er.b­ro­wse­r.m­ana­ge.a­ll­_co­oki­es.each {|cookie|}

result = page.e­val­uat­e_s­cri­pt('4 + 4');

save_a­nd_­ope­n_pagealso, use

Rspec Capybara Cheat Sheet

bindi­ng.pry

Rspec Cheat Sheet