-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebdemoTests.cs
58 lines (51 loc) · 1.68 KB
/
WebdemoTests.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
using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using Webdemo.PageObjects;
namespace SeleniumWebdriver
{
[TestFixture]
public class WebdemoTests
{
private IWebDriver driver;
[SetUp]
public void SetupTest()
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("--no-sandbox"); // Bypass OS security model, to run in Docker
options.AddArgument("--headless");
driver = new ChromeDriver(options);
}
[TearDown]
public void TeardownTest()
{
try
{
driver.Quit();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
}
//[Test, Property("Requirement", "XT-10")]
[Test, Property("Requirement", "CALC-2")]
public void ValidLogin()
{
LoginPage loginPage = new LoginPage(driver).Open();
LoginResultsPage loginResultsPage = loginPage.Login("demo", "mode");
Assert.AreEqual(loginResultsPage.Title, "Welcome Page");
Assert.IsTrue(loginResultsPage.Contains("Login succeeded"));
}
//[Test, Property("Requirement", "XT-10")]
[Test, Property("Requirement", "CALC-2")]
public void InvalidLogin()
{
LoginPage loginPage = new LoginPage(driver).Open();
LoginResultsPage loginResultsPage = loginPage.Login("demo", "invalid");
Assert.AreEqual(loginResultsPage.Title, "Error Page");
Assert.IsTrue(loginResultsPage.Contains("Login failed"));
}
}
}