Created
September 10, 2014 16:16
-
-
Save hatelove/c6140d21ce20717777ee to your computer and use it in GitHub Desktop.
103 web testing demo sample - FluentAutomation
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
Feature: 登入 | |
Scenario: 登入成功 | |
Given 我連到登入頁面 | |
And 我在帳號輸入 "joey" | |
And 我在密碼輸入 "1234" | |
When 我按下登入按鈕 | |
Then 應該被導到首頁 | |
Scenario: 登入失敗 | |
Given 我連到登入頁面 | |
And 我在帳號輸入 "joey" | |
And 我在密碼輸入 "abc" | |
When 我按下登入按鈕 | |
Then 畫面應該出現 "帳號或密碼有誤" 的錯誤訊息 |
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
using System; | |
using FluentAutomation; | |
using TechTalk.SpecFlow; | |
namespace SeleniumSample.Tests | |
{ | |
[Binding] | |
public class 登入Steps : FluentTest | |
{ | |
public 登入Steps() | |
{ | |
// 要用多瀏覽器跑web測試時,只需要加入Bootstrap()中即可 | |
SeleniumWebDriver.Bootstrap( | |
SeleniumWebDriver.Browser.Chrome | |
//SeleniumWebDriver.Browser.Firefox | |
//SeleniumWebDriver.Browser.InternetExplorer | |
); | |
} | |
[Given(@"我連到登入頁面")] | |
public void Given我連到登入頁面() | |
{ | |
I.Open("http://localhost:29021/login"); | |
} | |
[Given(@"我在帳號輸入 ""(.*)""")] | |
public void Given我在帳號輸入(string account) | |
{ | |
I.Enter(account).In("#id"); | |
} | |
[Given(@"我在密碼輸入 ""(.*)""")] | |
public void Given我在密碼輸入(string password) | |
{ | |
I.Enter(password).In("#password"); | |
} | |
[When(@"我按下登入按鈕")] | |
public void When我按下登入按鈕() | |
{ | |
I.Click("input[type=\"submit\"]"); | |
} | |
[Then(@"應該被導到首頁")] | |
public void Then應該被導到首頁() | |
{ | |
I.Assert.Url("http://localhost:29021"); | |
} | |
[Then(@"畫面應該出現 ""(.*)"" 的錯誤訊息")] | |
public void Then畫面應該出現的錯誤訊息(string message) | |
{ | |
I.Assert.Text(message).In("#message"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment