Skip to content

Commit 15863a8

Browse files
committed
Added basic smoke tests
1 parent d47cb55 commit 15863a8

File tree

4 files changed

+79
-11
lines changed

4 files changed

+79
-11
lines changed

Framework/Framework.projitems

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ItemGroup>
1212
<Compile Include="$(MSBuildThisFileDirectory)BasePage.cs" />
1313
<Compile Include="$(MSBuildThisFileDirectory)Navigation\IMastHead.cs" />
14+
<Compile Include="$(MSBuildThisFileDirectory)Pages\CartPage.cs" />
1415
<Compile Include="$(MSBuildThisFileDirectory)Pages\HomePage.cs" />
1516
<Compile Include="$(MSBuildThisFileDirectory)Pages\MyAccountPage.cs" />
1617
<Compile Include="$(MSBuildThisFileDirectory)Utilities\ExcelLibrary.cs" />

Framework/Pages/CartPage.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using OpenQA.Selenium;
2+
3+
namespace Framework.Pages
4+
{
5+
class CartPage : BasePage
6+
{
7+
private readonly By PageTitle = By.CssSelector(".entry-title");
8+
public CartPage(IWebDriver driver) : base(driver) { }
9+
public bool PageDisplays() => IsDisplayed(PageTitle, 10);
10+
}
11+
}

Framework/Pages/MyAccountPage.cs

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using OpenQA.Selenium;
5-
using NUnit.Framework;
6-
using UI_Tests.Data;
1+
using OpenQA.Selenium;
72

83
namespace Framework.Pages
94
{
105
class MyAccountPage : BasePage
116
{
12-
private readonly By PageTitle = By.LinkText("My account");
13-
private readonly By LoggInContent = By.CssSelector(".woocommerce-MyAccount-content");
14-
private readonly By UsernameText = By.Id("username");
15-
private readonly By PasswordText = By.Id("password");
16-
private readonly By LoginButton = By.CssSelector("input[name='login']");
7+
private readonly By PageTitle = By.LinkText("My account");
8+
private readonly By LoggInContent = By.CssSelector(".woocommerce-MyAccount-content");
9+
private readonly By UsernameText = By.Id("username");
10+
private readonly By PasswordText = By.Id("password");
11+
private readonly By LoginButton = By.CssSelector("input[name='login']");
12+
private readonly By LogoutButton = By.LinkText("Log out");
13+
private readonly By DashboardLink = By.LinkText("Dashboard");
14+
private readonly By OrdersLink = By.LinkText("Orders");
15+
private readonly By DownloadsLink = By.LinkText("Downloads");
16+
private readonly By AddressesLink = By.LinkText("Addresses");
17+
private readonly By AccountDetailsLink = By.LinkText("Account details");
18+
private readonly By LogoutLink = By.LinkText("Logout");
1719
public MyAccountPage(IWebDriver driver) : base(driver) { }
1820
public bool PageDisplays() => IsDisplayed(PageTitle, 10);
1921
public bool UserContentDisplays() => IsDisplayed(LoggInContent, 10);
@@ -24,5 +26,10 @@ public MyAccountPage Login(string username, string password)
2426
Click(LoginButton);
2527
return this;
2628
}
29+
public MyAccountPage Logout()
30+
{
31+
Click(LogoutButton);
32+
return this;
33+
}
2734
}
2835
}

UI Tests/Smoke/Smoke.cs

+49
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Smoke : BaseTest
1010
{
1111
private DataObject Data;
1212
private HomePage Home;
13+
private CartPage Cart;
1314
private MyAccountPage MyAccount;
1415
//private LoginWorkflow LoginWorkflow;
1516
//private BirthSearchPage BirthSearch;
@@ -25,6 +26,7 @@ class Smoke : BaseTest
2526
Data = new DataObject();
2627
Home = new HomePage(Driver);
2728
MyAccount = new MyAccountPage(Driver);
29+
Cart = new CartPage(Driver);
2830
//LoginWorkflow = new LoginWorkflow(Driver);
2931
//BirthSearch = new BirthSearchPage(Driver);
3032
//DeathSearch = new DeathSearchPage(Driver);
@@ -52,6 +54,53 @@ public void LoginTest()
5254

5355
Assert.That(MyAccount.UserContentDisplays);
5456
}
57+
[Test]
58+
[Category("Smoke")]
59+
public void LogoutTest()
60+
{
61+
//SetData(1);
62+
//LoginWorkflow.InitialLogin(Data);
63+
Home.GoTo(BaseUrl);
64+
Assert.That(Home.PageDisplays);
65+
66+
Home.MyAccount();
67+
68+
Assert.That(MyAccount.PageDisplays);
69+
70+
MyAccount.Login("autocustomer", "65O@ZTr8sVFW5L^4#pw&ayag");
71+
72+
Assert.That(MyAccount.UserContentDisplays);
73+
74+
MyAccount.Logout();
75+
}
76+
[Test]
77+
[Category("Smoke")]
78+
public void EmptyCartMessage()
79+
{
80+
//SetData(1);
81+
Home.GoTo(BaseUrl);
82+
Assert.That(Home.PageDisplays);
83+
84+
Home.Cart();
85+
86+
Assert.That(Cart.PageDisplays);
87+
88+
Assert.That(Driver.PageSource, Does.Contain("Your cart is currently empty."));
89+
}
90+
[Test]
91+
[Category("Smoke")]
92+
public void UnavailableCheckoutMessage()
93+
{
94+
//SetData(1);
95+
Home.GoTo(BaseUrl);
96+
Assert.That(Home.PageDisplays);
97+
98+
Home.Cart();
99+
100+
Assert.That(Cart.PageDisplays);
101+
102+
Assert.That(Driver.PageSource, Does.Contain("Your cart is currently empty."));
103+
}
55104
private void SetData(int row)
56105
{
57106
//Data.Target = Lib.Data(row, "target");

0 commit comments

Comments
 (0)