Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save daipresents/fd0c5836a18c27197f00f60e881bd3c3 to your computer and use it in GitHub Desktop.

Select an option

Save daipresents/fd0c5836a18c27197f00f60e881bd3c3 to your computer and use it in GitHub Desktop.
WebDriverとRspecを使いWindows環境で画面テストを自動化してみる
cd <DEVKIT_INSTALL_DIR>
ruby dk.rb init
---
- C:/Ruby193
ruby dk.rb install
# Proxyがある場合
set http_proxy=http://proxy-name:port
#rspecインストール
gem install rspec
gem install selenium-webdriver
require "selenium-webdriver"
require "rspec"
include RSpec::Expectations
describe "Test" do
before(:each) do
@driver = Selenium::WebDriver.for :firefox
@base_url = "http://daipresents.com/"
@driver.manage.timeouts.implicit_wait = 30
@verification_errors = []
end
after(:each) do
@driver.quit
@verification_errors.should == []
end
it "test_" do
@driver.get(@base_url + "/")
@driver.find_element(:link, "Home").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
end
# coding:utf-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment