1. Sel-dot-net documentation
SelDotNet =
Selenium
WebDriver + NUnit
(Cooperation is
strength)
A quick guidance to automate testing with SelDotNet framework
Sel-Dot-Net Documentation Page i
2. RELEASE 1.0
Nov 14th 2011
By Jason Truong
(Trương Minh Sử Nhiên tmsnhien@gmail.com)
http://seldotnet.blogspot.com
DOWNOAD
http://www.mediafire.com/?384xdcw8dsz06
Sel-Dot-Net Documentation Page ii
3. Contents
Contents
Contents ..........................................................................................iii
Chapter 1: Introduction .................................................................... 1
1. What is SelDotNet?............................................................... 1
2. Features ................................................................................. 1
1) Page Oriented Design .................................................... 1
2) Separated GUI Map ....................................................... 2
3) Test Multi-language supported web application ........... 2
4) Separated Test Data ....................................................... 2
5) Self-Described scripts .................................................... 2
6) Self-Logged testing scripts ............................................ 3
7) Parameterize .................................................................. 4
8) Have a utility library ...................................................... 4
9) Have a mechanism to prevent trivial defects ................. 4
3. How it works? ....................................................................... 4
4. Pros and Cons ....................................................................... 5
1) Pros ................................................................................ 5
2) Cons ............................................................................... 5
Chapter 2: Creates A Test Project .................................................... 6
5. Create a test project ............................................................... 6
Chapter 3: Automate a Test Case..................................................... 8
1. Configs the test project ......................................................... 8
2. Identifies Test Cases ............................................................. 8
3. Identifies Pages and actions .................................................. 8
1) Page ............................................................................... 8
2) Actions ........................................................................... 9
4. Implements the Pages and Actions ....................................... 9
1) Implements Home Page ................................................. 9
2) Implements Method SubmitLoginForm ........................ 9
3) Implements AssertLoggedSuccess .............................. 10
5. Identifies & Implements Test Class and Test Method ........ 10
1) Identifies Test class and test method ........................... 10
2) Implements Test Class ................................................. 11
3) Implements Test Method ............................................. 11
6. Maps GUI............................................................................ 12
Sel-Dot-Net Documentation Page iii
4. Contents
1) Briefly introduction to GUI Mapping .......................... 12
2) Recognition mechanism .............................................. 12
3) Create Mapping file ..................................................... 12
4) Loads GUI map to Homepage ..................................... 13
7. Executes the test (built assembly) ....................................... 13
1) Executes the test .......................................................... 13
2) Modifies the test to let it failed .................................... 14
Chapter 4: Case Study – More Login Test Cases .......................... 15
1. Identifies More Login Test Cases ....................................... 15
2. Identifies Page and Actions ................................................ 15
3. Implements Page Actions ................................................... 16
1) AssertEmptyAlertMessage .......................................... 16
2) AssertWrongCredentials .............................................. 17
4. Implements Testing Class and Method ............................... 17
1) Login with empty username and/or password ............. 17
2) Login with incorrect username and/or password ......... 18
5. Maps GUI............................................................................ 18
6. Builds and Runs the Test .................................................... 18
7. Optimizes the test................................................................ 19
1) Override DoTestSetUp, DoTestTearDown method .... 19
2) Loads Test Data From Excel file ................................. 20
3) Loads Test Data from DB ............................................ 21
Sel-Dot-Net Documentation Page iv
5. Chapter 1: Introduction
Chapter 1: Introduction
Objectives: Introduce briefly about
SelDotNet framework, features, workflow,
pros and cons…We assumed that you got
familiar with Selenium WebDriver, NUnit
and have a background of software testing
and automated testing domain.
1. What is SelDotNet?
B
5
SelDotNet = Selenium + SelDotNet is an automated testing framework that uses Selenium
NUnit WebDriver Client and NUnit.
Cooperation is strength
It is a right way to automate testing with Selenium WebDriver.
Please visit our blog at http://seldotnet.blogspot.com for further,
up-to-date information.
2. Features
B
6
1) Page Oriented Design
B
4
2
In order to design tests, we just identify the pages and their actions.
Then, in the testing classes, we call these actions. Therefore, the
tests are readable and clear.
Look at a page structured folder, we also know that how many
modules/pages are automated.
Look at a test structured folder, we know which features are
automated.
Sel-Dot-Net Documentation Page 1
6. Chapter 1: Introduction
Figure 1Page Oriented Design
2) Separated GUI Map
B
5
2
GUI Map is a repository that stores recognized information for
mapping a test objects to real objects.
By this separated storing, once there is any change from
Application under Test (AUT) on GUI, it does not affect to the
source code. In other words, user are easily to make the tests
adaptable with the changes by modify the GUI Map.
SelDotNet stores GUI Map in excel files under the
DeliverablesMaps folder.
3) Test Multi-language supported web application
B
6
2
By separated GUI Map storing, SelDotNet is able to test multi-
language supported web application. Each language will have own
a GUI Map. We can change configuration to let the test run with a
specific language easily.
4) Separated Test Data
B
7
2
It does not affect to the source code either if we want to change the
set of testing data. Since, SelDotNet store this information
separately in DeliverablesTestData folder.
SelDotNet also have library to load testing data in two forms:
• Database query
• And Excel files
5) Self-Described scripts
B
8
2
The tests automatically describe themselves by using SelDotNet
framework. E.g. looking in to this block of code, you also
understand the testing workflow.
Sel-Dot-Net Documentation Page 2
7. Chapter 1: Introduction
class LoginPage
{
public void SubmitLoginForm(string username,
string password)
{
Editbox("UsernameTextbox").Set(username);
Editbox("PasswordTextbox").Set(password);
Button("LoginButton").Click();
}
public void AssertShowWelcomeText()
{
Label("WelcomeText").AssertPresent();
}
}
class TestLoginFeature
{
public void TestLogin(string username, string
password)
{
LoginPage loginPage = new LoginPage();
loginPage.SubmitLoginForm(username,
password);
loginPage.AssertShowWelcomeText();
}
}
6) Self-Logged testing scripts
B
9
2
If there is any error, SelDotNet will capture screen shot for later
reference. It also logs reproducing steps to the report to let user
know about the problem.
Sel-Dot-Net Documentation Page 3
8. Chapter 1: Introduction
Figure 2 Self Logged/Reported Test Scripts
7) Parameterize
B
0
3
SelDotNet inherits this feature from NUnit to make tests
parameterized easily.
8) Have a utility library
B
1
3
9) Have a mechanism to prevent trivial defects
B
2
3
3. How it works?
B
7
Look at below workflow, the test project is structured in two main
parts:
• Development: that stores source code such as classes…
• Deliverables: that stores configuration information, GUI
Map, Test data, Built Assemblies…
Sel-Dot-Net Documentation Page 4
9. Chapter 1: Introduction
Figure 3 How it works
4. Pros and Cons
B
8
1) Pros
B
3
• As mentioned at feature section, SelDotNet has many good
features that are not found in the original Selenium
WebDriver.
• SelDotNet is quite free.
• SelDotNet has a blog to let you post feedbacks or request
for new feature.
2) Cons
B
4
3
• Taking time for learning
• (Let us know other cons that you found.)
Sel-Dot-Net Documentation Page 5
10. Chapter 2: Creates A Test Project
Chapter 2: Creates A Test Project
Objectives: This chapter provides a short
guidance to create a start-up project with
Visual Studio 2008 (Net 3.5) or Visual
Studio 2010 (Net 4.0)
5. Create a test project
B
9
Create a test project like below steps:
a. Open Visual studio IDE
b. Creates a new project with
i. Type is library
ii. Language is a language that you are most
familiar. C# is recommended. Since, it is
used as default language for all of examples
in this document.
iii. .Net Framework should be 3.5/4.0.
Figure 4 Creates a test project as library project in Visual Studio
c. Creates a structured folder like this
Sel-Dot-Net Documentation Page 6
11. Chapter 2: Creates A Test Project
Figure 5: Structure of a test project folder
d. Set reference
i. Downloads SelDotNet_Netxx.zip (xx is
.NET framework version that works with
your configuration) at
http://www.mediafire.com/?384xdcw8dsz06
ii. Extracts the zip files
iii. Set as project’s references
e. At the Tests folder, create an entry class, EntryPoint
like this:
using SelDotNet.Framework;
using NUnit.Framework;
[SetUpFixture]
public class EntryPoint : BaseTestProject
{
}
Sel-Dot-Net Documentation Page 7
12. Chapter 3: Automate a Test Case
Chapter 3: Automate a Test Case
Objectives: This chapter provides basic
steps to automate a login test case.
Website: http://seldotnet.echovietnam.org
or download website source, example at
http://www.mediafire.com/?384xdcw8dsz06
1. Configs the test project
B
0
1
Reuse the above project, the very early step is to configs file
‘Deliverablesconfigs.xls’ to make the tests run properly.
• Language: en
• BrowserType: firefox ( you can specify as iexplore or
chrome if needed.)In case of chrome, you need to download
chromedriver_win_xxxx.zip file and place at the
‘DeliverablesAssemblies’ folder
• BaseUrl: http://seldotnet.echovietnam.org/
• Timeout : 100 or a better number in second
• ConnectionString: empty. Since this sample we don’t
connect to DB.
• CaptureScreenShotOnError: Yes. (Remember to empty the
folder DeliverablesTestResultScreenShot often. Since it
stores screenshots)
2. Identifies Test Cases
B
1
TC01_ValidLogin Login with valid username password Success
Test Data: # Steps Expected Result
- Username: non 1 Open website's url The application launched
empty string
2 Enter username to username textbox
- Password:
3 Enter password to password textbox
'Password'
- Show ‘ Welcome admin to
our world!’
4 Click Sub button - Show logout link.
Figure 6 Valid Login Test Case
3. Identifies Pages and actions
B
2
1
1) Page
B
5
3
Sel-Dot-Net Documentation Page 8
13. Chapter 3: Automate a Test Case
According to the test case, we should have a page is LoginPage
that contains Login form
2) Actions
B
6
3
We have to main actions:
- Submit login form with a specified username, password
o Enter a specified username to username textbox
o Enter a specified password to password textbox
o Click on the Submit button
- Check if information shows correctly
o Check if the welcome message displays correctly as
specified in expected result
o Check if the logout link presents
4. Implements the Pages and Actions
B
3
1
1) Implements Home Page
B
7
3
At folder ‘Development/Pages’ creates a class name HomePage
inherits from SelDotNet.Framework.BasePage like this.
Creates a constructor receive IWebDriver (a class of Selenium
WebDriver) object as a browser.
using System;
using SelDotNet.Framework; //using SelDotNet
framework
using OpenQA.Selenium;//using Selenium library
namespace SampleProject.Development.Pages
{
class HomePage: BasePage
{
public HomePage(IWebDriver browser)
: base(browser)
{
//Clicks on the login link
Link("LoginLink").Click();
}
}
}
2) Implements Method SubmitLoginForm
B
8
3
Implements the SubmitLoginForm like below code snippet. We use
the class Editbox, Button method of BasePage class.
For now, the name “UsernameTextbox”, “PasswordTextbox”,
“SubmitButton” is just names of the test objects. You can name
Sel-Dot-Net Documentation Page 9
14. Chapter 3: Automate a Test Case
them whatever you like. We will map them with real test objects
later in step of mapping gui.
We need to declare a variable username to store which user
logged in for later using.
string username;
public void SubmitLoginForm(string username,
string password)
{
this.username = username;
Editbox("UsernameTexbox").Set(username);
Editbox("PasswordTextbox").Set(password);
Button("SubmitButton").Click();
}
3) Implements AssertLoggedSuccess
B
9
3
In this method, we perform these actions
- Asserts that the welcome message present. This is a
dynamic label, so,
o Firstly we define the expected message.
o Add this message to the map object
o Call AssertPresent() of Label class to asserts that
this label present
- Asserts that logout link present by calling AssertPresent()
method. Once again, we name the object name as
“LogoutLink”, we will map it later.
public void AssertLoggedSuccess(){
//Defines expected welcome message
string expectedMessage = "";
expectedMessage = String.Format("Welcome
{0} to our world!", username);
//adds it back to map object
map.Add("WelcomeLabel", expectedMessage);
//Assertst that this label presents
Label("WelcomeLabel").AssertPresent();
//Also asserts that the logout link
present
Link("LogoutLink").AssertPresent();
}
5. Identifies & Implements Test Class and Test Method
B
4
1
1) Identifies Test class and test method
B
0
4
In this example, we have only one test case. That means we will
have a test method in a test class (NUnit knowledge).
Sel-Dot-Net Documentation Page 10
15. Chapter 3: Automate a Test Case
2) Implements Test Class
B
1
4
At the ‘DevelopmentTests’, creates a class as TF01_LoginFeature
that inherits from the BaseTestFixture class like below
namespace SampleProject.Development.Tests
{
class TF01_LoginFeature:BaseTestFixture
{
}
}
3) Implements Test Method
B
2
4
The test method has two string parameters are username and
password. We can parameterize them by using attribute TestCase
of NUnit.
Creates a method name TC01_Login_CorrectCredentials_Success.
- The name is in format
<TC><NN>_<Action>_<Condition>_<ExpectedResult>
- Starts browser by StartBrowser() method. It returns an
IWebDriver object.
- Create object of HomePage, pass above browser object as
parameter.
- Calls SubmitLoginForm() method to login
- Calls AssertLoggedSuccess to check if logged success or
not
- Quit the home page.
- We should include these using statements to make the test
works
using SelDotNet.Framework;
using SampleProject.Development.Pages;
using OpenQA.Selenium;
using NUnit.Framework;
//Tests Login feature
[TestCase("Jason","seldotnet")]
[TestCase("Ben", "seldotnet")]
public void
TC01_Login_CorrectCredentials_Success(string
username, string password)
{
IWebDriver browser = StartBrowser();
HomePage homePage = new
HomePage(browser);
homePage.SubmitLoginForm(username,
password);
homePage.AssertLoggedSuccess();
Sel-Dot-Net Documentation Page 11
16. Chapter 3: Automate a Test Case
homePage.Quit();
}
6. Maps GUI
B
5
1
1) Briefly introduction to GUI Mapping
B
3
4
The test now is mostly complete. The last step is mapping test
objects ( e.g. “UsernameTextbox”, “PasswordTextbox”,
”SubmitButton”,…) to real test objects.
The mapping mechanism of SelDotNet is defining a GUI Map
excel file and placing at ‘DeliverablesMapsLanguage’ folder.
The language now is EN (refer to Confabs the test project step)
A gui mapping sheet has two columns
- Property name: A friendly name to make the test as self-
described. Such as: UsernameTextbox.
- Value: value of that property or identifying value that use to
identify real object on AUT
2) Recognition mechanism
B
4
SelDotNet uses the format of locator (identification/Recognition)
as same as locator of Selenium IDE. So, it’s recommended to
install Selenium IDE plugin for Firefox to make the GUI Map.
Figure 7Using Selenium IDE plugin of Firefox to identify object mapping
3) Create Mapping file
B
5
4
1. At ‘DeliverablesMapsLanguage’ folder, create an excel file
with name SelDotNetMap.xls,
2. Rename the first sheet as ‘HomePage’
3. Creates two columns ‘Property’ and ‘Value’
4. Copies test object names from the HomePage class to column
Property column
Sel-Dot-Net Documentation Page 12
17. Chapter 3: Automate a Test Case
5. Using Selenium IDE to identifies value ( you can also use
Firebug, Firepath… or view source code to see what is name,
id,… of test object)
The GUI map file now is like below image
Property Value
UsernameTexbox id=username
PasswordTextbox id=password
SubmitButton id=submit
LogoutLink id=logout
LoginLink id=loginLink
Figure 8: GUI mapping
4) Loads GUI map to Homepage
B
6
4
We needs to finish the last step is loading GUI map to HomePage
class.
At the constructor of the class, We adds
LoadMap("SelDotNetMap.xls", "HomePage");
For loading map. The constructor now is
public HomePage(IWebDriver browser)
: base(browser)
{
LoadMap("SelDotNetMap.xls", "HomePage");
//Clicks on the login link
Link("LoginLink").Click();
}
The test now is finish, we can build to generate assembly now and
run the test on next step.
7. Executes the test (built assembly)
B
6
1
1) Executes the test
B
7
4
Require: Click here to download and install latest version of NUnit
Open NUnit runner
Open the assembly was built from the last step
Click Run button to run.
Analyze the test result if failed
Sel-Dot-Net Documentation Page 13
18. Chapter 3: Automate a Test Case
Figure 9 Run the test
2) Modifies the test to let it failed
B
8
4
In order to see the failed steps, change the expected message above
from
expectedMessage = String.Format("Welcome {0} to our
world!", username);
to
expectedMessage = String.Format("Welcome {0} to our
home!", username);
Build and run the above test, you will see that the test failed
Figure 10: Failed Test and Reproducing Step
Sel-Dot-Net Documentation Page 14
19. Chapter 4: Case Study – More Login Test Cases
Chapter 4: Case Study – More Login
Test Cases
Objectives:
This chapter continues automate other
login cases, using
AssertAlertPresentWithText, AcceptAlert,
AssertTextEquals….Load test data from
excel file Database
1. Identifies More Login Test Cases
B
7
1
Login with empty username
TC02_EmptyLogin and/or password Show alert box
Test Data: # Steps Expected Result
username and/or 1 Open website's url The application launched
password is empty Enter username to username
2 textbox
Enter password to password
3 textbox
- Shows alertbox
- 'Please enter Username' ( in cases of empty
username and/or empty password)
- 'Please enter Password' ( in case of emtpy password
4 Click Login button and not empty username)
Login with incorrect
TC03_IncorrectLogin credentials Show Error Message
Test Data: # Steps Expected Result
Incorrect credentials 1 Open website's url The application launched
(wrong username Enter username to username
and /or password) 2 textbox
Enter password to password
3 textbox
4 Click Login button Show a message:"Wrong username or password"
2. Identifies Page and Actions
B
8
1
In these two test cases, we don’t need more action login. We can
reuse the action Submit Login Form at previous chapter.
We just add more two assertion action
Sel-Dot-Net Documentation Page 15
20. Chapter 4: Case Study – More Login Test Cases
- Check if an alert box in case of empty username, empty
password
- Check if error message displays in case of wrong username
password
3. Implements Page Actions
B
9
1
1) AssertEmptyAlertMessage
B
9
4
In this method, we use
AssertAlertPresentWithText(expectedMessage) to assert
that an alert box presents with an expected message.
After checking, we call call AcceptAlert(); or
DismissAlert(); Accepting an alert box or dismissing it.
public enum EmptyAlertMessages {
EMPTY_USERNAME,
EMPTY_PASSWORD
}
public void
AssertEmptyAlertMessage(EmptyAlertMessages msgType)
{
string expectedMessage = "";
switch (msgType)
{
case
EmptyAlertMessages.EMPTY_USERNAME:
expectedMessage =
Property("EmptyUsernameMessage");
break;
case
EmptyAlertMessages.EMPTY_PASSWORD:
expectedMessage =
Property("EmptyPasswordMessage");
break;
}
//Assert that an alert message displays
with a specific text
AssertAlertPresentWithText(expectedMessage);
//Accept alert box
AcceptAlert();
//Or you can call DismissAlert()
//DismissAlert();
}
Sel-Dot-Net Documentation Page 16
21. Chapter 4: Case Study – More Login Test Cases
2) AssertWrongCredentials
B
0
5
There is two ways to assert that a message displays in the web
page:
- Asserts that the label present. Insert to map file a label
object with the value is the expected message. This way is
not strictly. It just check if the page contains that message
or not.
- If the message is displayed as a text of a web element. Call
AssertTextEquals(msg). This way is strictly and more
precise.
public void AssertWrongCredentials(){
//Asserts that the error web element has
text equal with expected message
Element("ErrorElement").AssertTextEquals(
Property("WrongCredentialMessage")
);
//Or check if the web page contains a
text
//Label("WrongCredentialMessage").AssertPresent();
}
4. Implements Testing Class and Method
B
0
2
1) Login with empty username and/or password
B
1
5
[TestCase("", "password",
HomePage.EmptyAlertMessages.EMPTY_USERNAME)]
[TestCase("", "",
HomePage.EmptyAlertMessages.EMPTY_USERNAME)]
[TestCase("username", "",
HomePage.EmptyAlertMessages.EMPTY_PASSWORD)]
public void
TC02_Login_EmptyCredentials_ShowAlertMsg(string
username, string password,
HomePage.EmptyAlertMessages msgType)
{
IWebDriver browser = StartBrowser();
HomePage homePage = new
HomePage(browser);
homePage.SubmitLoginForm(username,
password);
homePage.AssertEmptyAlertMessage(msgType);
homePage.Quit();
}
Sel-Dot-Net Documentation Page 17
22. Chapter 4: Case Study – More Login Test Cases
2) Login with incorrect username and/or password
B
2
5
[TestCase("wrong username","wrong password")]
public void
TC03_Login_InCorrectCredentials(string username,
string password)
{
IWebDriver browser = StartBrowser();
HomePage homePage = new
HomePage(browser);
homePage.SubmitLoginForm(username,
password);
homePage.AssertWrongCredentials();
homePage.Quit();
}
5. Maps GUI
B
1
2
In this chapter, we have more 4 items in GUI Map that needs
mapping like below table. You can get it easily by Selenium IDE
Figure 11: Get GUI Maps by Selenium IDE
EmptyUsernameMessage Please enter username
EmptyPasswordMessage Please enter password
ErrorElement id=errorMsg
WrongCredentialMessage Wrong username or password
6. Builds and Runs the Test
B
2
It’s complete now. You can build and run the test
Figure 12: Test Result
Sel-Dot-Net Documentation Page 18
23. Chapter 4: Case Study – More Login Test Cases
7. Optimizes the test
B
3
2
1) Override DoTestSetUp, DoTestTearDown method
B
3
5
We see that in the three test method about we repeat these lines of
code:
IWebDriver browser = StartBrowser();
HomePage homePage = new HomePage(browser);
//Do some thing with homepage object.
homePage.Quit();
We can optimize this by override the DoTestSetup and
DoTestTearDown methods to avoid this
HomePage homePage = null;
public override void DoTestSetUp()
{
IWebDriver browser = StartBrowser();
homePage = new HomePage(browser);
}
public override void DoTestTearDown()
{
homePage.Quit();
}
And in the test method, we remove redundant statement, it will be
like this
class TF01_LoginFeature:BaseTestFixture
{
HomePage homePage = null;
public override void DoTestSetUp()
{
IWebDriver browser = StartBrowser();
homePage = new HomePage(browser);
}
public override void DoTestTearDown()
{
homePage.Quit();
}
//Tests Login feature
[TestCase("Jason","seldotnet")]
[TestCase("Ben", "seldotnet")]
public void
TC01_Login_CorrectCredentials_Success(string
username, string password)
{
homePage.SubmitLoginForm(username,
password);
homePage.AssertLoggedSuccess();
Sel-Dot-Net Documentation Page 19
24. Chapter 4: Case Study – More Login Test Cases
}
[TestCase("", "password",
HomePage.EmptyAlertMessages.EMPTY_USERNAME)]
[TestCase("", "",
HomePage.EmptyAlertMessages.EMPTY_USERNAME)]
[TestCase("username", "",
HomePage.EmptyAlertMessages.EMPTY_PASSWORD)]
public void
TC02_Login_EmptyCredentials_ShowAlertMsg(string
username, string password,
HomePage.EmptyAlertMessages msgType)
{
homePage.SubmitLoginForm(username,
password);
homePage.AssertEmptyAlertMessage(msgType);
}
[TestCase("wrong username","wrong password")]
public void
TC03_Login_InCorrectCredentials(string username,
string password)
{
homePage.SubmitLoginForm(username,
password);
homePage.AssertWrongCredentials();
}
}
2) Loads Test Data From Excel file
B
4
5
In the test TC01_Login_CorrectCredentials_Success, we are
able to supply more test cases by adding attribute
[TestCase("username","password")]. It is a good solution but
not the best. Since after built, we could not change the test data.
SelDotNet provide some method to load test data from external
resources that we don’t need to change the test code if we just need
to change the test data.
Step 1: Creates test data excel file
B
6
5
1- At the ‘DeliverablesTest Data’ folder, create an excel file
name LoginFeature.xls
2- Creat a sheet ‘ValidLogin”
3- Create three columns
a. Username: stores username
b. Password: stores password
c. Run: the name must be exactly [Run]. Just stores
value is ‘Y’,’y’ to indicate that the row of data will
be run and other value for not run.
Sel-Dot-Net Documentation Page 20
25. Chapter 4: Case Study – More Login Test Cases
Username Password Run
Jason seldotnet Y
Ben seldotnet Y
Sue seldotnet N
Lady Gaga seldotnet Y
Obama seldotnet Y
Clinton seldotnet N
Figure 13: Test Data
Step 2: Loads test data
B
7
5
1- In the LoginFeature class, creates a method to load data
public string[][] ValidLoginTestData()
{
return LoadTestData_FromExcel(
"LoginFeature"
, "ValidLogin");
}
2- Replace TestCase attribute on test method
TC01_Login_CorrectCredentials_Success to
[TestCaseSource("ValidLoginTestData")]
public void
TC01_Login_CorrectCredentials_Success(string
username, string password)
{
homePage.SubmitLoginForm(username,
password);
homePage.AssertLoggedSuccess();
}
3- Build and reload tests, you will see the test cases are
generated from excel file. From now on, you can change
test case data without changing code.
Figure 14: Test cases generated from test data
3) Loads Test Data from DB
B
5
Similar with load test data from excel file, SeltDotNet provides
some methods to load testdata from DB.
We can change like this
public string[][] ValidLoginTestData()
{
Sel-Dot-Net Documentation Page 21
26. Chapter 4: Case Study – More Login Test Cases
string sql = "Select top 5 username, password
from tblUsers";
return LoadTestData_ExecSQL(sql);
}
Requirement:
- ConnectionString must be specified at the Configs.xls
Since this test doesn’t have connection string so, we can’t apply
this method.
Sel-Dot-Net Documentation Page 22