Created
May 11, 2016 07:18
-
-
Save daipresents/fd0c5836a18c27197f00f60e881bd3c3 to your computer and use it in GitHub Desktop.
WebDriverとRspecを使いWindows環境で画面テストを自動化してみる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd <DEVKIT_INSTALL_DIR> | |
| ruby dk.rb init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - C:/Ruby193 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ruby dk.rb install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Proxyがある場合 | |
| set http_proxy=http://proxy-name:port | |
| #rspecインストール | |
| gem install rspec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem install selenium-webdriver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding:utf-8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rspec test.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment