-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpecFlow_Selenium_Boilerplate.txt
85 lines (71 loc) · 2.26 KB
/
SpecFlow_Selenium_Boilerplate.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Start VS studio with new project "SpecFlow_Selenium_Boilerplate" as class library
Install follwoing NuGet packages
Selenium.WebDriver (3.141.0)
Selenium.WebDriver.ChromeDriver (79.0.3945.3600)
SpecFlow (3.1.80)
MSTest.TestFramework (2.0.0)
MSTest.TestAdapter (2.0.0)
Add following folders under project "SpecFlow_Selenium_Boilerplate"
Save changes and restart project
Remove class1.cs
Create BaseTest.cs file under folder "Tests"
Under BaseTest.cs
Add directives:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Configuration;
using System.Threading;
Edit default class into following:
[TestClass]
public class TestBase
{ }
Build project - verify Build: 1 succeeded
Under BaseTest.cs
Add following property under class TestBase
protected static IWebDriver driver;
public TestContext TestContext { get; set; }
private string appURL;
Add constructor
public TestBase() { }
Add 2 methods as specified below
[TestInitialize]
public void CreateDriver()
{
appURL = ConfigurationManager.AppSettings.Get("TrelloBaseURL");
driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
driver.Navigate().GoToUrl(appURL + "/");
}
[TestCleanup]
public void QuitDriver()
{
if (driver != null)
driver.Quit();
}
Add configuration file (App.config) to store base app URL under project root
Content as listed:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<specFlow>
<unitTestProvider name="mstest.v2" />
</specFlow>
<appSettings>
<add key="BaseURL" value="http://todomvc.com/examples/react-alt/#/" />
</appSettings>
</configuration>
Create first test class () with following
Directives:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
Initial class setup
namespace SpecFlow_Selenium_Boilerplate.Tests
{
[TestClass]
public class DefaultPageLoadingTest : TestBase {
}
}
Add constructor
public LoginTest() { }
Add page object for the ToDo page