$30 off During Our Annual Pro Sale. View Details »

e2e_prototype_capybara.pdf

 e2e_prototype_capybara.pdf

mokuo

May 10, 2018
Tweet

More Decks by mokuo

Other Decks in Programming

Transcript

  1. ܦྺ • େֶจܥ • Πϯλʔϯʢखಈςετ, WordPressʣ • ࣾձਓ̍೥໨ • SIer

    (SE) • ࣾձਓ̎೥໨ • ॴଐɿࣗࣾύοέʔδ։ൃɾൢച ← ຊ೔͸ίίͰͷ࿩ • ग़޲ɿRailsडୗ։ൃ • ݱࡏɿSansan
  2. CFML (ColdFusion Markup Language) <cfif type IS "Date"> <cfoutput>#DateFormat(Now())#</cfoutput> <cfelseif

    type IS "Time"> <cfoutput>#TimeFormat(Now())#</cfoutput> <cfelse> <cfoutput>#TimeFormat(Now())#, #DateFormat(Now())#</cfoutput> </cfif> ࢀߟ"EPCF$PME'VTJPO ϑϩʔ੍ޚ
  3. σΟϨΫτϦߏ੒ . !"" .env.sample !"" .gitignore !"" .ruby-version !"" Gemfile

    !"" Gemfile.lock !"" README.md #"" spec !"" features !"" pages !"" spec_helper.rb #"" support
  4. .env ͷઆ໌ ؀ڥม਺ આ໌ ྫ 4:45&.@63- γεςϜͷ63- IUUQTFYBNQMFDPN "%.*/@-0(*/ ؅ཧऀͷϩάΠϯ*%

    MPHJO "%.*/@1"44 ؅ཧऀͷύεϫʔυ QBTTXPSE )&"%-&44 ϔουϨεϞʔυͰ ࣮ߦ͢Δ͔ USVF
  5. spec_helper.rbʢલ൒ʣ require 'selenium-webdriver' require 'capybara/rspec' require 'tapp' require 'dotenv' require

    'byebug' Dotenv.load Capybara.configure do |capybara_config| capybara_config.default_driver = :selenium_chrome capybara_config.default_max_wait_time = 10 # seconds end Capybara.register_driver :selenium_chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_argument('headless') if ENV['HEADLESS'] == 'true' Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.javascript_driver = :selenium_chrome
  6. spec_helper.rbʢޙ൒ʣ require 'support/constants' require 'pages/base_page' # ܧঝ͢ΔͷͰɺઌʹಡΈࠐΜͰ͓͘ require 'pages/admin/base_page' #

    ܧঝ͢ΔͷͰɺઌʹಡΈࠐΜͰ͓͘ require 'pages/user/base_page' # ܧঝ͢ΔͷͰɺઌʹಡΈࠐΜͰ͓͘ Dir[Constants::APP_ROOT.join('spec/pages/**/*.rb')].each { |f| require f } Dir[Constants::APP_ROOT.join('spec/support/**/*.rb')].each { |f| require f } include SupportMacros include LoginMacros include CourseMacros include GroupMacros include UserMacros include CourseGroupMacros include AdminMacros include InquiryMacros include QuestionnaireMacros include SeminarMacros include PortalMenuMacros include LmsSettingMacros
  7. ڞ௨ॲཧ͸Ϟδϡʔϧʹ੾Γग़͢ module LoginMacros def admin_login visit “#{ENV[‘SYSTEM_URL']}/admin_login" admin_login_page = Admin::LoginPage.new(page)

    admin_login_page.set_id(ENV['ADMIN_LOGIN']) admin_login_page.set_pass(ENV['ADMIN_PASS']) admin_login_page.login end def user_login(id, pass) visit “#{ENV[‘SYSTEM_URL']}/user_login" user_login_page = User::LoginPage.new(page) user_login_page.set_id(id) user_login_page.set_pass(pass) user_login_page.login end end
  8. ϢʔβʔϩάΠϯϖʔδ module User class LoginPage < BasePage def set_id(id) page.fill_in

    'login', with: id end def set_pass(pass) page.fill_in 'password', with: pass end def login page.click_on 'ϩάΠϯ' User::TopPage.new(page) end end end
  9. ϙΠϯτ • ॻ੶ͳͲͰΠϯϓοτ͢Δ • Ruby on Rails Λࢀߟʹ͢Δ • Capybara

    ʹ͍ͭͯ͸ɺҏ౻३Ұ͞Μͷهࣄ • ࢖͑ΔRSpecೖ໳ɾͦͷ4ʮͲΜͳϒϥ΢β ૢ࡞΋ࣗ༝ࣗࡏʂٯҾ͖Capybaraେࣙయʯ