Skip to content

Instantly share code, notes, and snippets.

@gelias
Created July 19, 2012 05:21
Show Gist options
  • Save gelias/3140936 to your computer and use it in GitHub Desktop.
Save gelias/3140936 to your computer and use it in GitHub Desktop.
Preenchendo um campo do tipo text
require 'rubygems'
require 'watir-webdriver'
require 'rspec'
describe "Look for browser elements" do
FIRST_NAME = 'Guilherme'
before(:each) {puts 'inicou'}
after(:each) {@firefox.close unless @firefox.nil?}
it "Fill first name field" do
# Cria uma instancia do firefox e abre o formulário no google docs
@firefox = Watir::Browser.new :firefox
@firefox.goto 'http://bit.ly/M1mjNB'
# Busca o text field conforme o atributo id especificado. Espera ele aparecer na pagina e depois preenche
first_name_field = @firefox.text_field(:id => 'entry_0')
first_name_field.wait_until_present
first_name_field.set FIRST_NAME
# Busca o valor digitado e compara
filled_name = first_name_field.value
filled_name.should == FIRST_NAME
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment