| TestCase | Key Word | Argument1 | Argument2 | Argument3 |
| loadSahi | "books_lib.sah" | |||
| Check shopping cart total | [Documentation] | Smoke test for add books | ||
| login | "test" | "secret" | ||
| addBooks | 3 | 2 | 1 | |
| verifyTotal | 1640 | |||
| logout | ||||
| Test login error message | [Documentation] | Checks Invalid login message | ||
| login | "test" | "bad password" | ||
| verifyNotLoggedIn | ||||
| verifyErrorMessage | "Invalid username or password" | |||
| loadSahi | "books_lib.sah" |
function login($username, $password){
_setValue(_textbox("user"), $username);
_setValue(_password("password"), $password);
_click(_submit("Login"));
}
function addBooks($numJava, $numRuby, $numPython){
_setValue(_textbox("q", _near(_cell("Core Java"))), $numJava);
_setValue(_textbox("q", _near(_cell("Ruby for Rails"))), $numRuby);
_setValue(_textbox("q", _near(_cell("Python Cookbook"))), $numPython);
_click(_button("Add"));
}
function verifyTotal($total){
_assertEqual($total, _textbox("total").value);
}
function logout(){
_click(_button("Logout"));
}
function verifyNotLoggedIn(){
_assertExists(_textbox("user"));
}
function verifyErrorMessage($msg){
_assert(_isVisible(_div("errorMessage")));
_assertEqual($msg, _getText(_div("errorMessage")));
}
| Expand All | Collapse All | |||||||||
| loadSahi | "sample_lib.sah" | ||||||||
| Check shopping cart total | [Documentation] | Smoke test for add books | |||||||
| login | "test" | "secret" | |||||||
_setValue(_textbox("user"), "test"); at Mar 9, 2011 11:37:33 AM
_setValue(_password("password"), "secret"); at Mar 9, 2011 11:37:33 AM
_click(_submit("Login")); at Mar 9, 2011 11:37:33 AM
| |||||||||
| addBooks | 3 | 2 | 1 | ||||||
_setValue(_textbox("q", _near(_cell("Core Java"))), 3); at Mar 9, 2011 11:37:35 AM
_setValue(_textbox("q", _near(_cell("Ruby for Rails"))), 2); at Mar 9, 2011 11:37:35 AM
_setValue(_textbox("q", _near(_cell("Python Cookbook"))), 1); at Mar 9, 2011 11:37:35 AM
_click(_button("Add")); at Mar 9, 2011 11:37:35 AM
| |||||||||
| verifyTotal | 1640 | ||||||||
_assertEqual(1640, _textbox("total").value);
Assertion Failed. Expected:[1640] Actual:[1650] at Mar 9, 2011 11:37:46 AM | |||||||||
| logout | |||||||||
_click(_button("Logout")); at Mar 9, 2011 11:37:48 AM
| |||||||||
| Test login error message | [Documentation] | Checks Invalid login message | |||||||
| login | "test" | "bad password" | |||||||
_setValue(_textbox("user"), "test"); at Mar 9, 2011 11:37:49 AM
_setValue(_password("password"), "bad password"); at Mar 9, 2011 11:37:49 AM
_click(_submit("Login")); at Mar 9, 2011 11:37:49 AM
| |||||||||
| verifyNotLoggedIn | |||||||||
_assertExists(_textbox("user")); at Mar 9, 2011 11:37:50 AM
| |||||||||
| verifyErrorMessage | "Invalid username or password" | ||||||||
_assert(_isVisible(_div("errorMessage"))); at Mar 9, 2011 11:37:50 AM
_assertEqual("Invalid username or password", _getText(_div("errorMessage"))); at Mar 9, 2011 11:37:50 AM
| |||||||||
| Test Case | Key word | Argument 1 | Argument 2 | Argument 3 | Very first line of sheet |
| Blank lines are ignored | |||||
| loadSahi | "custom_lib.sah" | Loads a Sahi script with required function definitions | |||
| Test Case One | Step One | Param1 | Param2 | New test case started. StepOne(Param1, Param2) is called. | |
| Step Two | Param3 | StepTwo(Param3) is called | |||
| Test Case Two | Step One | 25 | "age" | New test case started. String values are quoted | |
| Step Two | Param5 | ||||
| Test Case Three | [Documentation] | Some description about the test case | [Documentation] is useful for, well, documentation | ||
| Step One | 25 | "age" | New test case started. String values are quoted | ||
| // | Step Two | Param5 | Commented step using // | ||
| Step Two | Param6 | ||||
| login | "test" | "secret" |
| _assertEqual | _getText(_cell("msg")) | "abcd" |
| $userId=createUserInGroup | "My name" | "My group" | ||
| verifyUserCreated | $userId | "My name" | "My group" |
| $msg= | _getText(_cell("msg")) | ||
| _assertEqual | $msg | "abcd" |
| [Global] | [SetUp] | |||
| _log | "In Global Setup" | |||
| login | "test" | "secret" | ||
| [TearDown] | ||||
| _click | _button("Logout") | |||
| _log | "In Global Teardown" | |||
| Verify books total | addBooks | 3 | 2 | 1 |
| verifyTotal | 1650 | |||
| Verify books again | addBooks | 3 | 2 | 2 |
| verifyTotal | 2000 |
| _log | "In Global Setup" | |||
| login | "test" | "secret" | ||
| addBooks | 3 | 2 | 1 | |
| verifyTotal | 1650 | |||
| _click | _button("Logout") | |||
| _log | "In Global Teardown" | |||
| _log | "In Global Setup" | |||
| login | "test" | "secret" | ||
| addBooks | 3 | 2 | 2 | |
| verifyTotal | 2000 | |||
| _click | _button("Logout") | |||
| _log | "In Global Teardown" |
| Create AddBooksCheck Key Word | [CreateKeyword] | Add Books Check | [CreateKeyword] command creates a keyword called "Add Books Check" | |||
| [Arguments] | $java | $ruby | $python | $total | These are the arguments or parameters that "Add Books Check" takes as input | |
| [Documentation] | Data drivable add books check | |||||
| addBooks | $java | $ruby | $python | |||
| verifyTotal | $total |
| Add Books Check | 3 | 2 | 1 | 1650 |
| addBooks | 3 | 2 | 1 | |
| verifyTotal | 1650 |
| Data Driven Example | [Keyword] | Add Books Check | Starts a testcase "Data Drivern Example" AddBooksCheck function will be called for the data set below. | |||
| [SetUp] | This will be called BEFORE each row of data | |||||
| login | "test" | "secret" | ||||
| [TearDown] | This will be called AFTER each row of data | |||||
| _click | _button("Logout") | |||||
| [Documentation] | java | ruby | python | total | Ignored by Sahi. Makes test case more readable | |
| [Data] | 3 | 2 | 1 | 1650 | [Data] denotes start of data | |
| 4 | 5 | 0 | 2100 | |||
| 0 | 1 | 9 | 3350 |
| login | "test" | "secret" | |||
| Add Books Check | 3 | 2 | 1 | 1650 | |
| _click | _button("Logout") | ||||
| login | "test" | "secret" | |||
| Add Books Check | 4 | 5 | 0 | 2100 | |
| _click | _button("Logout") | ||||
| login | "test" | "secret" | |||
| Add Books Check | 0 | 1 | 9 | 3350 | |
| _click | _button("Logout") | ||||