=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') | |
=Interacting with forms= | |
fill_in('First Name', :with => 'John') | |
fill_in('Password', :with => 'Seekrit') | |
fill_in('Description', :with => 'Really Long Text…') | |
choose('A Radio Button') | |
check('A Checkbox') | |
uncheck('A Checkbox') | |
attach_file('Image', '/path/to/image.jpg') | |
select('Option', :from => 'Select Box') | |
=scoping= | |
within("//li[@id='employee']") do | |
fill_in 'Name', :with => 'Jimmy' | |
end | |
within(:css, "li#employee") do | |
fill_in 'Name', :with => 'Jimmy' | |
end | |
within_fieldset('Employee') do | |
fill_in 'Name', :with => 'Jimmy' | |
end | |
within_table('Employee') do | |
fill_in 'Name', :with => 'Jimmy' | |
end | |
=Querying= | |
page.has_xpath?('//table/tr') | |
page.has_css?('table tr.foo') | |
page.has_content?('foo') | |
page.should have_xpath('//table/tr') | |
page.should have_css('table tr.foo') | |
page.should have_content('foo') | |
page.should have_no_content('foo') | |
find_field('First Name').value | |
find_link('Hello').visible? | |
find_button('Send').click | |
find('//table/tr').click | |
locate("//*[@id='overlay'").find("//h1").click | |
all('a').each { |a| a[:href] } | |
=Scripting= | |
result = page.evaluate_script('4 + 4'); | |
=Debugging= | |
save_and_open_page | |
=Asynchronous JavaScript= | |
click_link('foo') | |
click_link('bar') | |
page.should have_content('baz') | |
page.should_not have_xpath('//a') | |
page.should have_no_xpath('//a') | |
=XPath and CSS= | |
within(:css, 'ul li') { ... } | |
find(:css, 'ul li').text | |
locate(:css, 'input#name').value | |
Capybara.default_selector = :css | |
within('ul li') { ... } | |
find('ul li').text | |
locate('input#name').value |
This comment has been minimized.
This comment has been minimized.
Nice...bookmarked this |
This comment has been minimized.
This comment has been minimized.
Useful. Thanks. |
This comment has been minimized.
This comment has been minimized.
Thanks. |
This comment has been minimized.
This comment has been minimized.
Awesome, thank you. |
This comment has been minimized.
This comment has been minimized.
Excellent. Produced a PDF for this (and gave you credit in the metadata): http://cl.ly/0q1y282S3O2j110h0O2u |
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
click('Button Value') > click_on('Button Value') |
This comment has been minimized.
This comment has been minimized.
Thanks, here's bitcookie 8635 |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Thanks....its a quick reference i was looking for. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This is great! |
This comment has been minimized.
This comment has been minimized.
Just what I was looking for ... many thanks! |
This comment has been minimized.
This comment has been minimized.
+1 |
This comment has been minimized.
This comment has been minimized.
+1! |
This comment has been minimized.
This comment has been minimized.
is there any command for refresh button and back button on browser ???? |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
(y) thanks |
This comment has been minimized.
This comment has been minimized.
+1 for updates :-) |
This comment has been minimized.
This comment has been minimized.
thank you so much!!you made my life easier <3 <3 |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
nice! |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
+1 |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
This comment has been minimized.
Awesome, thanks! |
This comment has been minimized.
This comment has been minimized.
@zhengjia I believe click method has changed to click_on . Thanks for the sheet |
This comment has been minimized.
This comment has been minimized.
Really thks! |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
This comment has been minimized.
Amazing! |
This comment has been minimized.
This comment has been minimized.
Thank you, very useful! |
This comment has been minimized.
This comment has been minimized.
Thanks!
|
This comment has been minimized.
This comment has been minimized.
This is awesome, thanks! |
This comment has been minimized.
This comment has been minimized.
Life saver. Thx. |
This comment has been minimized.
This comment has been minimized.
@FalloutX
|
This comment has been minimized.
This comment has been minimized.
within("li#employee") do within(:xpath, "//li[@id='employee']") do You might want to update your gist. |
This comment has been minimized.
This comment has been minimized.
Very Handy, Thanks! |
This comment has been minimized.
This comment has been minimized.
Hi, it is very useful. Just for "add value", in multiple select exists |
This comment has been minimized.
This comment has been minimized.
Anyone have an up-to-date fork? |
This comment has been minimized.
This comment has been minimized.
If you can't find select via
do
|
This comment has been minimized.
This comment has been minimized.
cool! |
This comment has been minimized.
This comment has been minimized.
New ability to choose option from a specific radio group (as of 2.2.0): choose("radio_group_selector", option: "Option 5") |
This comment has been minimized.
This comment has been minimized.
I'm maintaining one that can be run and asserted on: https://github.com/cirosantilli/rails-cheat/blob/master/app/test/integration/capybara_test.rb |
This comment has been minimized.
This comment has been minimized.
When debugging, I have found |
This comment has been minimized.
This comment has been minimized.
great ! |
This comment has been minimized.
This comment has been minimized.
it's really good and helpfull |
This comment has been minimized.
This comment has been minimized.
cool thanks! |
This comment has been minimized.
This comment has been minimized.
Thank you! |
This comment has been minimized.
This comment has been minimized.
good job, thank you |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
thank you |
This comment has been minimized.
This comment has been minimized.
I've added all the comments above to mine: https://gist.github.com/elfassy/11399304 |
This comment has been minimized.
This comment has been minimized.
Good work!! |
This comment has been minimized.
This comment has been minimized.
U saved my Day!! |
This comment has been minimized.
This comment has been minimized.
I have a 2 radio buttons with the same id and label, only different values, (true, false)....anything I can do to choose false? |
This comment has been minimized.
This comment has been minimized.
select "United States", from: "Country", :match => :first You can use this if you want to select the first one on the dropdown list. |
This comment has been minimized.
This comment has been minimized.
page.title |
This comment has been minimized.
This comment has been minimized.
Since the version 2.1.0 of capybara there are methods on the session to deal with the title. |
This comment has been minimized.
This comment has been minimized.
I'm finding visibility testing to be easier, with: |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I have that error undefined method `visit' for #Object:0x007f9355878f08 (NoMethodError) |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
Ultimate |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
Capybara automatically waits for asynchronous operations to complete. When you try to find an element that isn't on the page, it waits and retries until it is there, or a timeout duration elapses. The wait time is defined at Capybara.default_wait_time Here are the methods that waits:
Here are the methods that doesn't wait:
Note that Capybara.default_wait_time has been changed to Capybara.default_max_wait_time |
This comment has been minimized.
This comment has been minimized.
Thanks!! |
This comment has been minimized.
This comment has been minimized.
Comes in handy ALL the time. Thanks :) |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Thanks man! |
This comment has been minimized.
This comment has been minimized.
Thanks |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
nice |
This comment has been minimized.
This comment has been minimized.
Thank you for this |
This comment has been minimized.
This comment has been minimized.
Thank you for this |
This comment has been minimized.
This comment has been minimized.
Thanks a lot! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
it's a great help for me |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Is the "fill_in" function taking in the ID of a textfield or the label associated with the textfield? |
This comment has been minimized.
This comment has been minimized.
@shashwathi You can feed both of them, it handles that automatically |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
great job ;) |
This comment has been minimized.
This comment has been minimized.
super handy, thanks! |
This comment has been minimized.
This comment has been minimized.
thx! |
This comment has been minimized.
This comment has been minimized.
thx |
This comment has been minimized.
This comment has been minimized.
I did find on this doc a way to find a text (and then click on it), |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
how to fill in text in masked input field? |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Thanks for this - very handy! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Good stuff |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Been using this for years now without saying thanks... Thanks! |
This comment has been minimized.
This comment has been minimized.
Nice |
This comment has been minimized.
This comment has been minimized.
To debug |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
o/ |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I have used this resource so many times I just wanted to say thanks! |
This comment has been minimized.
This comment has been minimized.
I really appreciate you putting this together. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
find("input[attribute='value']") where input is an input tag, and attribute is something like name I have found these command useful. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
Really helpful! |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This is great. Thank you! |
This comment has been minimized.
This comment has been minimized.
Compact, printable version: https://drive.google.com/file/d/0ByAb4A9TD5wBTF9kLVcyUFNrQUU/view?usp=sharing |
This comment has been minimized.
This comment has been minimized.
Nice @hooverlunch, thanks! |
This comment has been minimized.
This comment has been minimized.
Guys good day. Can you help me on how can i create a test report when i am using capybara-cucumber in my automation. What gem should i need to install and how should i invoke it. Thank you in advance. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I am unable to hit "enter" key , any solution? |
This comment has been minimized.
This comment has been minimized.
This is simple and great. Thanks! |
This comment has been minimized.
This comment has been minimized.
I'm always coming back to this. Thanks for a great list! |
This comment has been minimized.
This comment has been minimized.
Excellent! Thanks :) |
This comment has been minimized.
This comment has been minimized.
Awesome! |
This comment has been minimized.
This comment has been minimized.
Thanks for this great gist |
This comment has been minimized.
This comment has been minimized.
Great! |
This comment has been minimized.
This comment has been minimized.
Awesome, thanks! (FYI, this gist was used by LaunchAcademy here) |
This comment has been minimized.
This comment has been minimized.
When i use find(<name_of_object>).click, I get following error |
This comment has been minimized.
This comment has been minimized.
@vishakhapanat Did you find a solution for your error? |
This comment has been minimized.
This comment has been minimized.
To note, things like |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Hiii |
This comment has been minimized.
This comment has been minimized.
How do you wait for page to load in webrat? |
This comment has been minimized.
This comment has been minimized.
To match that
|
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
TY |
This comment has been minimized.
This comment has been minimized.
Thanks a lot. Helpful |
This comment has been minimized.
This comment has been minimized.
Amazing article! |
This comment has been minimized.
This comment has been minimized.
Is this up to date in July 2019? |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
Useful thanks ! |
This comment has been minimized.
This comment has been minimized.
thanks! |
This comment has been minimized.
This comment has been minimized.
thanks |
This comment has been minimized.
Awesome, thanks for this