Capybara. Exemplos de configuração. Com cucumber-rails. Com cucumber sem Rails. Tags para uso de JS. Nos steps do cucumber. Utilizando com RSpec

Similar documents
Cucumber and Capybara

Boletim Técnico. Esta implementação consiste em atender a legislação do intercâmbio eletrônico na versão 4.0 adotado pela Unimed do Brasil.

NAS 221 Remote Access Using Cloud Connect TM

External User Manual. Online Registration of Users of the Electronic System for the Management of Medicinal Products of Human Use of INFARMED, I.P.

Agile Web Application Testing

Online Statements. About this guide. Important information

SYSPRO App Store: Registration Guide

THINK SUCCESS MAKE IT HAPPEN ANNA NOT MISSING HER ENGLISH CLASS. myclass AN ENGLISH COURSE THAT FITS YOUR LIFE

Uma Ferramenta Essencial! Prof. Fred Sauer, D.Sc.

Access Manager. Help scenarios. Home. Access and permissions: Assigning or modifying access and permissions Copy permissions Manage Access

Exploring Web Testing Tools For Use In A Classroom

Register Manufacturer: Click on Register Manufacturer radio button, choose the State name and click on Login Button. The following screen appears:

Prova Escrita de Inglês

Initial Setup of Microsoft Outlook with Google Apps Sync for Windows 7. Initial Setup of Microsoft Outlook with Google Apps Sync for Windows 7

ParishSOFT Remote Installation

Inovando sistemas com arquiteturas elásticas

DocuSign for Microsoft Dynamics CRM

Setup guide for ebanking. member of staff for details. large print, on tape and on disk. Speak to a. This publication is also available in Braille,

Online Class Registration Quick Guide for Students

IBM BPM V8.5 Standard Consistent Document Managment

Initial Setup of Microsoft Outlook 2011 with IMAP for OS X Lion

Getting Started with WPM

03 infra TI RAID. MTBF; RAID Protection; Mirroring and Parity; RAID levels; write penalty

Prova Escrita de Inglês

Livezilla How to Install on Shared Hosting By: Jon Manning

SecureAnywhereTM Web Security Service

Android Bootcamp. Elaborado (com adaptações) a partir dos tutoriais:

Android App for SAP Business One. Z3moB1le App Version 1.00 Pagina 1 di 12.

Creating a generic user-password application profile

Addax Business Solutions - Support Services

DATA SHEET Setup Tutorial

In a browser window, enter the Canvas registration URL: silverlakemustangs.instructure.com

CRM: customer relationship management: o revolucionário marketing de relacionamento com o cliente P

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

Install MSU Google Drive on your Computer

Human Computer Interaction Final Project Tutorial. Hardware Inventory Management System (HIMS) By M. Michael Nourai

The Register Menu allows you to register, download, and activate licenses so that your players can run.

How To Make A Website More Popular

Wakanda Studio Features

webcrm App for HootSuite User Guide

Homepage / Login FAQ - VENDOR MANAGEMENT SYSTEM

Active Directory Integration for Greentree

REDES DE ARMAZENAMENTO E ALTA DISPONIBILIDADE

How do I Install and Configure MS Remote Desktop for the Haas Terminal Server on my Mac?

Behavior Driven Development

Security Upgrade FAQs

Google Trusted Stores Setup in Magento

Managed Devices - Web Browser/HiView

Lenovo Partner Access - Overview

SUMMARY. e-soft s.r.l.

3dCart Shopping Cart Software V3.X Gift Registry Guide

User Guide for Smart Former Gold (v. 1.0) by IToris Inc. team

ONLINE DISABILITY CERTIFICATE GUIDELINES FOR APPLICANTS

One-Time Password Contingency Access Process

Setup guide for ebanking

Parent Single Sign-On Quick Reference Guide

Windmill. Automated Testing for Web Applications

Seu servidor deverá estar com a versão 3.24 ou superior do Mikrotik RouterOS e no mínimo 4 (quatro) placas de rede.

Install and End User Reference Guide for Direct Access to Citrix Applications

Prova Escrita de Inglês

KETTERING EACCOUNTS WEB PORTAL HELP SHEET

Portal Recipient Guide

Security Testing with Selenium

Mobile Online Banking

Manual Activity after implementing note

ACORD. Lync 2013 Web-app Install Guide

Download and Launch Instructions for WLC Client App Program

3dCart Shopping Cart Software V3.X Affiliate Program Guide

Web+Center Version 7.x Windows Quick Install Guide 2 Tech Free Version Rev March 7, 2012

All mail administration activities can be carried out using the Domain Management Console.

WHMCS LUXCLOUD MODULE

InternetVista Web scenario documentation

Step by Step Guide for Upgrading Your NetCamPro Camera to Cloud Mode Using an Android Device

For Use with QR Code Scanner / Reader Enabled Applications

E-LEARNING STUDENT S MANUAL

(` Online Read Introduo ao Disciplined Agile Delivery: A Pequena Jornada de um Time gil do Scrum ao Continuous Delivery (Portuguese...

Enable Your Automated Web App Testing by WebDriver. Yugang Fan Intel

How To Use Optionbot 2.0 On A Pc Or Mac Or Mac (For Pc) Or Mac) Or Pc (For Mac)

DocuSign Connect for Salesforce Guide

Link / Login / Logout Page 2. Home Page Page 2. Home Page Breakdown by Levels Page 3. Home Page Breakdown by Columns Page 3

Gravity Forms: Creating a Form

How to use the Online Module Enrolment Application

Tufts University Human Resources New Hire Benefits Enrollment

Most of the security testers I know do not have

Self-Service Portal Registering, downloading & activating a soft token

Note: Password must be 7-16 characters and contain at least one uppercase letter and at least one number.

Sophos Mobile Control Startup guide. Product version: 3

McAfee One Time Password

IPA Help Desk. How to use Self-Service portal. [Version 1.0] [28/12/1435 H] FRM CC-UME-V001

Chromebook Reference Document

How To Read A Quarantine On Hb.Com

Transcription:

Capybara Exemplos de configuração Com cucumber-rails Com cucumber sem Rails rails generate cucumber:install -- capybara require 'capybara/cucumber' Capybara.app = MyRackApp Nos steps do cucumber When /I sign in/ do Tags para uso de JS @javascript Capybara.javascript_driver = :culerity Tags disponívels @javascript @selenium @culerity @rack_test Utilizando com RSpec require 'capybara/rspec' describe "the signup process", :type => :request do before :each do User.make(:email =>, :password => 'caplin') it "signs me in" do

DSL do Capybara feature "Signing up" do background do User.make(:email =>, :password => 'caplin') scenario "Signing in with correct credentials" do fill_in 'Password', :with => 'caplin' Isto é apenas uma forma de utilizar o RSpec. Habilitando o driver JS feature é um alias para describe, :type => :request background é um alias para before' scenario é um alias para it/specify describe 'some stuff which requires js', :js => true do it 'will use the default js driver' it 'will switch to one specific driver', :driver => :celerity Junto com Test::Unit class ActionDispatch::IntegrationTest include Capybara::DSL Capybara com qualquer aplicação Rack Capybara.app = MyRackApp Selecionando o Driver Capybara.default_driver = :selenium Capybara.current_driver = :rack_test # Este é o padrão se não mudarmos para outro na linha acima Capybara.use_default_driver #volta para o driver padrão A DSL

Navegando visit('/projects') visit(post_comments_path(post)) current_path.should == post_comments_path(post) Clicando em links e botões click_link('id-of-link') click_link('link Text') click_button('save') click_on('link Text') # clica em um link ou botão click_on('button Value') Interagindo com formulários 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') Verificando o conteúdo da página page.has_selector?('table tr') page.has_selector?(:xpath, '//table/tr') page.has_no_selector?(:content) page.has_xpath?('//table/tr') page.has_css?('table tr.foo') page.has_content?('foo') page.has_text?('foo') Verificando o conteúdo da página com RSpec page.should have_selector('table tr') page.should have_selector(:xpath, '//table/tr') page.should have_no_selector(:content) page.should have_xpath('//table/tr') page.should have_css('table tr.foo') page.should have_text('foo') page.should have_no_text('foo') page.html.should match /<span>/i Buscando find_field('first Name').value find_link('hello').visible? find_button('s').click find(:xpath, "//table/tr").click find("#overlay").find("h1").click all('a').each { a a[:href] } find('#navigation').click_link('home') find('#navigation').should have_button('sign out') Definindo escopos within("li#employee") do Rodando Javascript page.execute_script("$('body').empty()") result = page.evaluate_script('4 + 4'); within(:xpath, "//li[@id='employee']") do within_fieldset('employee') do within_table('employee') do

Debug save_and_open_page Mais exemplos Utilizando a DSL em qualquer lugar require 'capybara' require 'capybara/dsl' Capybara.default_driver = :culerity module MyModule include Capybara::DSL def login! within("//form[@id='session']") do Chamando servidores remotos visit('http://www.google.com') Capybara.current_driver = :selenium Capybara.app_host = 'http://www.google.com' visit('/') Capybara sem o servidor Rack interno Capybara.run_server = false Session require 'capybara' session = Capybara::Session.new(:culerity, my_rack_app) session.within("//form[@id='session']") do session. session.fill_in 'Password', :with => 'password' session. Seletores XPath within(:xpath, '//ul/li') { } find(:xpath, '//ul/li').text find(:xpath, '//li[contains(.//a[@href = "#"]/text(), "foo")]').value Seletores padrão Capybara.default_selector = :xpath find('//ul/li').text

Seletores personalizados Capybara.add_selector(:id) do xpath { id XPath.descant[XPath.attr(:id) == id.to_s] } Capybara.add_selector(:row) do xpath { num ".//tbody/tr[#{num}]" } Capybara.add_selector(:flash_type) do css { type "#flash.#{type}" } Adicionando drivers Capybara.register_driver :selenium do app Capybara::Selenium::Driver.new(app, :browser => :chrome) Capybara.register_driver :selenium_chrome do app Capybara::Selenium::Driver.new(app, :browser => :chrome) find(:id, 'post_123') find(:row, 3) find(:flash_type, :notice) Parte do Livro de Rails 3.1 de Rodrigo Urubatan Ferreira Jardim, guia de referência rápida publicado originalmente em http://www.urubatan.com.br