Test Automation Web and Windows application using Selenium, WinApp, C# and Visual Studio
This article I will demonstrate how to create a test project in Visual Studio and how to automate web application and window application
Content
1. Create a Test project in Visual Studio
2. Automate web application using selenium
3. Automate windows application using selenium and Appium
1. Create a Test project in Visual Studio
C# Test Project
Pre-requirements
Learn C# basic (Ref 5).
Install visual studio community edition (Ref 6)
1.Open Visual Studio
2.Click on File >> New >> Project
Figure 1
3.Then Select Test under Visual C#, Then select Unit Test Project (.NET Framework)
Rename the project as you wish (MyTestProject).
Figure 2
4.Now you will see the project as below
Figure 3
Figure 4
5. Open test explore
Click Test >> Windows >> Test Explorer
Figure 5
Then you will see new explorer which we can use to run and debug the test cases
Figure 6
6.Run Test case
Right click on the test method listed inside the test explorer. The click on Run Selected Tests.
Figure 7
7. Create first test case
First, we will writ simple add method (Ref 2)
public int Add(int FirstValue,int SecondValue)
{
var Result = FirstValue + SecondValue;
return Result;
}
public : Access modifier. This can be public, private, internal, protected (Ref 1)
int : return type. This can be int, string, double, long , void etc (Ref 3)
Add : Method name
var Result : This is variable to store the results (Ref 4)
return Result : Return the answer
Then we will writ test case to test the Add method
[TestMethod]
public void TestMethod1()
{
var Result = Add(2, 2);
if(Result==4)
{
Assert.IsTrue(true);
}
else
{
Assert.IsTrue(false);
}
}
Then run the test case.
If test case is passed, you will see green color mark as below
Figure 8
If your test case failed, you will see red color mark as below
Figure 9
Sample code
Figure 10
8.What is inheritance
References
No comments:
Post a Comment