Skip to content

Instantly share code, notes, and snippets.

@jakesorce
Created February 18, 2013 17:38
Show Gist options
  • Save jakesorce/4979105 to your computer and use it in GitHub Desktop.
Save jakesorce/4979105 to your computer and use it in GitHub Desktop.
require "selenium-webdriver"
require "rspec"
include RSpec::Expectations
describe "ConversationsTesting" do
before(:each) do
@driver = Selenium::WebDriver.for :firefox
@base_url = "https://canvas.beta.instructure.com/"
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = 30
@verification_errors = []
end
after(:each) do
@driver.quit
@verification_errors.should == []
end
it "test_conversations_testing" do
@driver.get(@base_url + "/conversations")
@driver.find_element(:css, "td > div.token_input.browsable").click
name_input = @driver.find_element("token_capture")
name_input.clear
name_input.send_keys "jake"
sleep 5
@driver.find_element(:css, "li.selectable").click
message_body = @driver.find_element(".conversation_body")
message_body.click
message_body.clear
message_body.send_keys "test"
@driver.find_element(:css, "button[type=submit]").click
end
def element_present?(how, what)
@driver.find_element(how, what)
true
rescue Selenium::WebDriver::Error::NoSuchElementError
false
end
def verify(&blk)
yield
rescue ExpectationNotMetError => ex
@verification_errors << ex
end
def close_alert_and_get_its_text(how, what)
alert = @driver.switch_to().alert()
if (@accept_next_alert) then
alert.accept()
else
alert.dismiss()
end
alert.text
ensure
@accept_next_alert = true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment