Skip to content

Instantly share code, notes, and snippets.

@FabricioFFC
Created March 15, 2011 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabricioFFC/871576 to your computer and use it in GitHub Desktop.
Save FabricioFFC/871576 to your computer and use it in GitHub Desktop.
Test using Watir to test a simple captcha
require 'rubygems'
require 'firewatir'
@browser = Watir::Browser.new
@browser.goto('http://www.eliasnogueira.info/arquivos_blog/selenium/desafio/soma.php')
number1 = @browser.label(:id, 'number1').text.to_i
number2 = @browser.label(:id, 'number2').text.to_i
sum = number1 + number2
@browser.text_field(:name, 'soma').value = sum
@browser.button(:name, 'submit').click
@browser.div(:id, 'examp').text
if @browser.div(:id, 'examp').text.include? "CORRETO"
puts "Parabéns você passou no desafio do @eliasnogueira"
else
puts "Dah! Você não passou no desafio do @eliasnogueira, tente novamente"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment