Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rubygems'
require 'spec'
require 'bewildr'
describe "my example app" do
it "should allow valid users to log in" do
#start the app and wait for the main window
@app, @main_window = Bewildr::Application.start_app_and_wait_for_window("c:\\my_app.exe", /My App v1.\d+/)
username_field = @main_window.get(:id => "username")
password_field = @main_window.get(:id => "password")
login_button = @main_window.get(:type => :button, :name => "Go")
#some initial checks...
username_field.should be_enabled
password_field.should be_enabled
password_field.is_password_field?.should be_true
#attempt login with invalid user
username_field.text = "invalidUser"
password_field.text = "s3cr3t"
login_button.click
#check we're not logged in
@main_window.get(:id => "login_message").text.should match("Wrong username or password")
#login with valid user
username_field.text = "ValidUser"
password_field.text = "s3cr3t"
login_button.click
#check to see that we're logged in
@main_window.wait_for_existence_of(:id => "welcome_message")
welcome_message = @main_window.get(:id => "welcome_message")
welcome_message.text.should match('Hi ValidUser')
#check to see that the login fields have gone
username_field.should_not exist
password_field.should_not exist
login_button.should_not exist
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment