Last active
April 22, 2022 01:01
-
-
Save bluerabbit/6227860 to your computer and use it in GitHub Desktop.
Revisions
-
bluerabbit revised this gist
Mar 14, 2017 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,6 +31,14 @@ uncheck('チェックボックス1') attach_file 'file', "#{fixture_path}/xxx.csv" ``` 最近はinput type=fileを隠してボタンを上に出してたりすることが多いので、その場合は`visible: false`が必要 ```ruby attach_file 'file', "#{fixture_path}/xxx.csv", visible: false ``` * セレクトボックスで選択 ```ruby -
bluerabbit revised this gist
Mar 18, 2016 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -101,6 +101,14 @@ page.should have_css("table#table_id tbody tr", count: 0) find('#css_selecter').should be_visible ``` * disabledかを検証する ```ruby expect(page).to have_checked_field '選択肢1', disabled: true expect(page).to have_button '登録', disabled: true ``` * テーブルが存在するか ```ruby -
bluerabbit revised this gist
Jul 31, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -112,8 +112,10 @@ should have_table('table') ```ruby should have_selector('button', value: '実行') should have_selector('h1#title', :content=>'Hello!') should have_css('#status.current') ``` * ボタンが存在するか ```ruby -
bluerabbit revised this gist
Nov 18, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -92,6 +92,7 @@ should have_field('id_or_label', with: 'value') ```ruby all('#table_id tr').should have(0).rows page.should have_css("table#table_id tbody tr", count: 0) ``` * 表示・非表示の検証をする -
bluerabbit revised this gist
Oct 16, 2014 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -146,12 +146,13 @@ binding.pry find(:xpath, '//li[contains(.//a[@href = "#"]/text(), "foo")]').value ``` * xpath引数を使ったfind * containsを使う事でclassに複数指定があってもヒットする ```ruby all(:xpath, "//a[contains(@class, 'target-class-name') and contains(text(), 'リンク名')]") ``` * findした要素の値をshouldではなく参照する ```ruby -
bluerabbit revised this gist
Oct 16, 2014 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -146,6 +146,12 @@ binding.pry find(:xpath, '//li[contains(.//a[@href = "#"]/text(), "foo")]').value ``` ```ruby all(:xpath, "//div[contains(@class, 'target-class-name')]") ``` - containsを使う事でclassに複数指定があってもヒットする * findした要素の値をshouldではなく参照する ```ruby -
bluerabbit revised this gist
Oct 9, 2014 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,13 +69,19 @@ should have_content '登録されました' should have_no_content 'エラーがしました' ``` * チェックボックス(radio)がチェックされて(いる|いない) ```ruby have_checked_field have_unchecked_field ``` * selectの値を検証する ```ruby page.should have_select('name', selected: 'selected_value') ``` * inputの値を検証する ```ruby -
bluerabbit revised this gist
Jan 8, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -114,6 +114,7 @@ find('#navigation').should have_button('Sign out') ``` * ある要素が表示されているか ```ruby should have_selector('#hoge_area', visible: true) ``` -
bluerabbit revised this gist
Jan 8, 2014 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -113,6 +113,11 @@ should have_selector('h1#title', :content=>'Hello!') find('#navigation').should have_button('Sign out') ``` * ある要素が表示されているか ```ruby should have_selector('#hoge_area', visible: true) ``` ### debug * 現在のページをブラウザで表示 -
bluerabbit revised this gist
Dec 26, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,7 +69,7 @@ should have_content '登録されました' should have_no_content 'エラーがしました' ``` * チェックボックス(selectboxまたはradio)がチェックされて(いる|いない) ```ruby have_checked_field -
bluerabbit revised this gist
Aug 21, 2013 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -56,6 +56,12 @@ current_path.should == '/pages/1' page.status_code.should be(200) ``` * タイトルタグの検証 ```ruby page.should have_title('たいとる') ``` * ページ内に期待する文字列が(ある|ない)か確認 ```ruby -
bluerabbit revised this gist
Aug 14, 2013 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -134,6 +134,13 @@ find(:xpath, '//li[contains(.//a[@href = "#"]/text(), "foo")]').value find('#id').text ``` * ボタンクリックする時にclick_on以外を使う ```ruby find('#id').click click_button 'id_or_label' ``` ### Link * http://rubydoc.info/github/jnicklas/capybara/frames -
bluerabbit revised this gist
Aug 14, 2013 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,8 +59,8 @@ page.status_code.should be(200) * ページ内に期待する文字列が(ある|ない)か確認 ```ruby should have_content '登録されました' should have_no_content 'エラーがしました' ``` * チェックボックスがチェックされて(いる|いない) @@ -91,14 +91,14 @@ find('#css_selecter').should be_visible * テーブルが存在するか ```ruby should have_table('table') ``` * セレクターを使った検証 ```ruby should have_selector('button', value: '実行') should have_selector('h1#title', :content=>'Hello!') ``` * ボタンが存在するか -
bluerabbit revised this gist
Aug 14, 2013 . 1 changed file with 95 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,56 +13,127 @@ fill_in 'id_or_label_text', with: 'yamada' ``` * ラジオボタンを選択 ```ruby choose 'ラジオボタン1' ``` * チェックボックスをチェック/非チェック ```ruby check('チェックボックス1') uncheck('チェックボックス1') ``` * ファイルの添付 ```ruby attach_file 'file', "#{fixture_path}/xxx.csv" ``` * セレクトボックスで選択 ```ruby select('カテゴリ1', from: 'カテゴリ') ``` * ボタンまたはリンクをクリック ```ruby click_on 'ボタンまたはリンク' ``` ### 検証 * 現在のページを確認 ```ruby current_path.should == '/pages/1' ``` * Http Statusを確認 ```ruby page.status_code.should be(200) ``` * ページ内に期待する文字列が(ある|ない)か確認 ```ruby have_content have_no_content ``` * チェックボックスがチェックされて(いる|いない) ```ruby have_checked_field have_unchecked_field ``` * inputの値を検証する ```ruby should have_field('id_or_label', with: 'value') ``` * テーブルの行数を検証する ```ruby all('#table_id tr').should have(0).rows ``` * 表示・非表示の検証をする ```ruby find('#css_selecter').should be_visible ``` * テーブルが存在するか ```ruby page.should have_table('table') ``` * セレクターを使った検証 ```ruby page.should have_selector('button', value: '実行') page.should have_selector('h1#title', :content=>'Hello!') ``` * ボタンが存在するか ```ruby find('#navigation').should have_button('Sign out') ``` ### debug * 現在のページをブラウザで表示 ```ruby save_and_open_page ``` * debuggerを起動 ```ruby binding.pry ``` ### 使ってはイケナイ(?!) * xpath引数を使ったfind ```ruby find(:xpath, '//li[contains(.//a[@href = "#"]/text(), "foo")]').value ``` * findした要素の値をshouldではなく参照する ```ruby find('#id').text ``` ### Link * http://rubydoc.info/github/jnicklas/capybara/frames -
bluerabbit revised this gist
Aug 14, 2013 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,11 +7,14 @@ visit '/pages/new' ``` * フォームに値を入力 ```ruby fill_in 'id_or_label_text', with: 'yamada' ``` * ラジオボタンを選択 * choose 'ラジオボタン1' * チェックボックスをチェック/非チェック * check('チェックボックス1') * uncheck('チェックボックス1') -
bluerabbit revised this gist
Aug 14, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,9 @@ visit '/pages/new' ``` * フォームに値を入力 * ```ruby * fill_in 'id_or_label_text', with: 'yamada' * ``` * ラジオボタンを選択 * choose 'ラジオボタン1' * チェックボックスをチェック/非チェック -
bluerabbit revised this gist
Aug 14, 2013 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,11 @@ ### 操作 * ページに移動 ```ruby visit '/pages/new' ``` * フォームに値を入力 * fill_in 'id_or_label_text', with: 'yamada' * ラジオボタンを選択 -
bluerabbit created this gist
Aug 14, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ ### 操作 * ページに移動 * visit '/pages/new' * フォームに値を入力 * fill_in 'id_or_label_text', with: 'yamada' * ラジオボタンを選択 * choose 'ラジオボタン1' * チェックボックスをチェック/非チェック * check('チェックボックス1') * uncheck('チェックボックス1') * ファイルの添付 * attach_file 'file', "#{fixture_path}/xxx.csv" * セレクトボックスで選択 * select('カテゴリ1', from: 'カテゴリ') * ボタンまたはリンクをクリック * click_on 'ボタンまたはリンク' ### 検証 * 現在のページを確認 * current_path.should == '/pages/1' * Http Statusを確認 * page.status_code.should be(200) * ページ内に期待する文字列が(ある|ない)か確認 * have_content * have_no_content * チェックボックスがチェックされて(いる|いない) * have_checked_field * have_unchecked_field * inputの値を検証する * should have_field('id_or_label', with: 'value') * テーブルの行数を検証する * all('#table_id tr').should have(0).rows * 表示・非表示の検証をする * find('#css_selecter').should be_visible * テーブルが存在するか * page.should have_table('table') * セレクターを使った検証 * page.should have_selector('button', value: '実行') * page.should have_selector('h1#title', :content=>'Hello!') * ボタンが存在するか * find('#navigation').should have_button('Sign out') ### debug * 現在のページをブラウザで表示 * save_and_open_page * debuggerを起動 * binding.pry ### 使ってはイケナイ(?!) * xpath引数を使ったfind * find(:xpath, '//li[contains(.//a[@href = "#"]/text(), "foo")]').value * findした要素の値をshouldではなく参照する * find('#id').text ### Link * http://rubydoc.info/github/jnicklas/capybara/frames