-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFormyTests.cs
241 lines (225 loc) · 8.9 KB
/
FormyTests.cs
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
using FormyProject;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using System.Threading;
namespace FormyTests
{
[TestClass]
public class FormyTests
{
OpenAndClose setup;
IWebDriver driver;
[TestInitialize]
public void SetUp()
{
setup = new OpenAndClose();
driver = setup.Open(null);
}
[TestCleanup]
public void TearDown()
{
setup.Close();
}
[TestMethod]
public void TestTitleAndLogo()
{
var title = new TitleAndLogo(driver);
Assert.AreEqual("Formy", driver.Title, "Title does not match");
Assert.AreEqual("FORMY", title.Logo.Text, "Can't find Logo");
}
[TestMethod]
public void TestCheckBoxes()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on checkbox from home
features.CheckBoxHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Checkboxes", features.CheckBoxHeader.Text, "Header does not match");
//clicks on check boxes 1 and 3
features.CheckBox1.Click();
features.CheckBox3.Click();
}
[TestMethod]
public void TestRadioButtons()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on radiobutton from home
features.RadioHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Radio buttons", features.RadioHeader.Text, "Header does not match");
//clicks on radio buttons 2 and 3
features.RadioButton2.Click();
features.RadioButton3.Click();
}
[TestMethod]
public void TestDatePicker()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on datepicker from home
features.DateHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Datepicker", features.DateHeader.Text, "Header does not match");
//sends date in datepicker and clicks enter
features.DatePickerBox.SendKeys("11/24/2020" + Keys.Enter);
}
[TestMethod]
public void TestDropDown()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on dropdown from home
features.DropDownHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Dropdown", features.DropDownHeader.Text, "Header does not match");
//clicks on drop down menu and clicks on fileupload
features.DropDownButton.Click();
features.DropDownItemFileUpload.Click();
}
[TestMethod]
public void TestFileUpload()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on fileupload from home
features.FileUploadHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("File upload", features.FileUploadHeader.Text, "Header does not match");
//sends image to file upload and then clicks on reset button
features.FileUploadField.SendKeys("14-Venice.jpg");
features.FileUploadResetButton.Click();
}
[TestMethod]
public void TestKeyBoardMouseInput()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on KeyboardMouseInput from home
features.KeyBoardHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Keyboard and Mouse Input", features.KeyBoardHeader.Text, "Header does not match");
//sends input in text box and clicks on button
features.KeyBoardTextBox.Click();
features.KeyBoardTextBox.SendKeys("Cheese Sandwich!!");
features.KeyBoardButton.Click();
}
[TestMethod]
public void TestAutocomplete()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on Autocomplete from home
features.AutoCompleteHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Autocomplete", features.AutoCompleteHeader.Text, "Header does not match");
//sends input in Address text box
features.AutoCompleteTextBox.Click();
features.AutoCompleteTextBox.SendKeys("4911 Tacoma Mall Blvd, Tacoma, WA, USA" +Keys.Enter);
}
[TestMethod]
public void TestScroll()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on Scroll from home
features.ScrollHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Large page content", features.ScrollHeader.Text, "Header does not match");
//sends input in Name and Date text box
var name = features.ScrollNameTextBox;
//actions will scroll down the page and select the element
Actions actions = new Actions(driver);
actions.MoveToElement(name);
name.Click();
name.SendKeys("John Sanders");
var date = features.ScrollDateTextBox;
date.Click();
date.SendKeys("09/07/2016");
}
[TestMethod]
public void TestSwitchWindow()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on SwitchWindow from home
features.SwitchWindowHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Switch Window", features.SwitchWindowHeader.Text, "Header does not match");
//clicks on new tab button
string originalHandle = driver.CurrentWindowHandle;
var newTab = features.OpenNewTabButton;
newTab.Click();
Thread.Sleep(2000);
Assert.AreEqual("Formy", driver.Title, "Title does not match");
string newHandle1 = driver.WindowHandles[1];
//closes the new window
driver.SwitchTo().Window(newHandle1).Close();
//switches back to original window
driver.SwitchTo().Window(originalHandle);
Thread.Sleep(2000);
//clicks on Open alert
features.OpenAlertButton.Click();
//Goes to Alert window and clicks Ok
IAlert alert = driver.SwitchTo().Alert();
alert.Accept();
}
[TestMethod]
public void TestModal()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on Modal from home
features.ModalHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Modal", features.ModalHeader.Text, "Header does not match");
//Clicks on OpenModal button
features.ModalOpenButton.Click();
Thread.Sleep(2000);
//Goes to Modal window and clicks on Close button
var closeButton = features.ModalCloseButton;
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].click();", closeButton);
}
[TestMethod]
public void TestDragDropBox()
{
var features = new Features(driver);
Thread.Sleep(2000);
//clicks on DragDrop from home
features.DragDropHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Drag the image into the box", features.DragDropHeader.Text, "Header does not match");
var image = features.DragImage;
var box = features.DragDropBox;
Thread.Sleep(1000);
//drags the image and puts in drop box
Actions actions = new Actions(driver);
actions.DragAndDrop(image, box).Build().Perform();
}
[TestMethod]
public void TestCompleteWebForm()
{
var form = new Form(driver);
Thread.Sleep(2000);
//clicks on CompletWebForm from home
form.FormHome.Click();
Thread.Sleep(2000);
Assert.AreEqual("Complete Web Form", form.FormHeader.Text, "Header does not match");
form.FirstName.SendKeys("Abraham");
form.LastName.SendKeys("Lincoln");
form.JobTitle.SendKeys("SDET");
form.EducationGradSchool.Click();
form.SexMale.Click();
Thread.Sleep(1000);
form.Experience5To9.Click();
form.Date.SendKeys("10/15/2022");
form.SubmitButton.Click();
Thread.Sleep(2000);
Assert.AreEqual("Thanks for submitting your form", form.FormSubmissionHeader.Text, "Header does not match");
Assert.AreEqual("The form was successfully submitted!", form.FormSubmissionAlert.Text, "Alert does not match");
}
}
}